C#
共 9 篇文章
ReadOnlyTest
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ReadOnlyTest { // 定义 point 结构 public struct point { public int x; public int y; // 定义 point 结构 的 构造函数 public point(int x, int y) { this.x = x; this.y = y; } } class Program { // 定义 动态常量 private static re…
2009-07-06 14:00 · C# · C · Linq · C++ · C#
Ch02 ConstTest
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConstTest { class Program { public const double piL = 3.14; // 定义 静态常量 static void Main(string[] args) { const double piH = 3.14159265; // 定义 静态常量 //piH = 3.15; Console.WriteLine("piL={0}", piL); Console…
2009-07-06 13:33 · C# · C · Linq · C++ · C#
IntToDoubleTest
隐式转换,通常 将 低类型 向 高类型 转换。 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace IntToDoubleTest { class Program { static void Main(string[] args) { double k; int i = 5; k = i; Console.WriteLine("k={0}",k); Console.ReadKey(); } } } 结果: k=5 诚品服饰 英伦男装 无条件退换
2009-07-06 11:26 · C# · C · Linq · C++ · C#
ch02 StructTest
struct 是 值类型,类 是 引用类型。 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace StructTest { // 定义 point 结构 public struct point { public int x; public int y; } // 定义 Rectangle 结构 public struct Rectangle { public point topleft; public point topright; public poi…
2009-07-06 11:09 · C# · C · Linq · C++ · C#
StrChTest
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace StrChTest { class Program { static void Main(string[] args) { char c; string str, s; c = 'I'; str = "you and "; s = " are friends"; str = str + c; // 字符串 加 字符 Console.WriteLine("str={0}", str); str = str…
2009-07-06 10:47 · C# · C · Linq · C++ · C#
DecimalTest
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DecimalTest { class Program { static void Main(string[] args) { decimal x; double y; x = 3.14159265358979323m; x = x / 3; y = (double)x; Console.WriteLine("x={0}", x); Console.WriteLine("y={0}", y); Cons…
2009-07-06 10:32 · C# · C · Linq · C++ · C#
2-2 使用 布尔变量
BoolTest using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BoolTest { class Program { static void Main(string[] args) { bool flagT, flagF; flagT = true; flagF = false; Console.WriteLine("The value of flagT is {0}", flagT); Console.WriteLine("The value o…
2009-07-06 10:23 · C# · C · Linq · C++ · C#
2-1 变量的赋值
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace VarTest { class Program { static void Main(string[] args) { string str; double Sum = 0, a, b, c; a = 20; b = 30; c = 40; Sum = a + b + c; str = "a+b+c="; Console.Write(str); Console.WriteLine("{0}",Sum);…
2009-07-06 10:17 · C# · C · Linq · C++ · C#
c#教程第一课:简单的欢迎程序
本节程要达到如下几个目的: 1.理解一个C#程序的基本结构。 2.初步了解"名称空间"的概念。 3.初步了解"类"的概念。 4.了解"Main"方法所做的工作。 5.学会如何读取命令行输入信息。 6.学会使用控制台输入/输出 (I/O)语句。 1.清单1-1. 一个简单的欢迎程序Welcome.cs // Namespace Declaration using System; // Program start class class WelcomeCSS { // Main begins program execution. public static void Main() { // Wr…
2009-04-14 04:53 · C# · C · 工作 · C++ · C#