#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();
}
}
}
我的第一个C#控制台程序
最新推荐文章于 2020-04-27 10:05:59 发布