我的第一个C#控制台程序

#region using directives

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#endregion

namespace supper
{
    namespace smashing
    {
        public class greate
        {
            double greatName;

        }
    }
}

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int myInt, nInterger;
            string sWho;
            string workDir;
            string usrName;

            nInterger = 17;
            sWho = " \" nInterger \u0022 is: " ;
            workDir = @"C:\Temp\Mydir";
            //Output text to the screen
            Console.WriteLine("The first app in beginning C# console programming!!");
            Console.WriteLine("{0} {1} {2}.",sWho, nInterger,workDir);

            Console.WriteLine("type you name here:");
            usrName = Console.ReadLine();
            Console.WriteLine("Welcome {0}!!", usrName);
          
            Console.WriteLine("input a int number:");
            myInt = Convert.ToInt32(Console.ReadLine());

            myInt = myInt & 0x8f;  //

            Console.WriteLine("you input number is: {0}", myInt);

            // test multiply array
            // <baseType>[,] <name>;
            // <baseType>[,,,] <name>;
            // double[,] hillheight = new double[3, 4]; //3行4列的数组
            // int[] arr={1,2,3};

            double[,] hillheight = {{0.36,5.36,4.33,4.12},
                                    {2.44,2.33,5.66,5.01},
                                    {3.21,4.56,5.23,6.12},
                                    {7.21,4.44,5.03,6.45},
                                    {0.21,5.44,6.03,1.01}};  //5*4的二维数组

            foreach (double height in hillheight)  //foreach --> Java、C# 、PHP
            {
                Console.WriteLine("__{0}__", height);
            }

            //test for string
            string myString = "This is a test string,yes,may be i'am very idot...";
            char[] sepparator = { ' ',',' };  //分割为什么要个char数组,
                                          //因为可以用多个字符来分割
            string[] myWords;

//             String.Split 方法有6个重载函数:
//             1) public string[] Split(params char[] separator)
//             2) public string[] Split(char[] separator, int count)
//             3) public string[] Split(char[] separator, StringSplitOptions options)
//             4) public string[] Split(string[] separator, StringSplitOptions options)
//             5) public string[] Split(char[] separator, int count, StringSplitOptions options)
//             6) public string[] Split(string[] separator, int count, StringSplitOptions options)

            myWords = myString.Split(sepparator, StringSplitOptions.RemoveEmptyEntries);

            foreach (string word in myWords)
            {
                Console.WriteLine("{0}", word);
            }
           

            Console.ReadKey();
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值