摘要:来源:http://mcdelfino.blog.51cto.com/2058744/661072不能为结构声明默认构造函数(一个无参数的构造函数).因为编译器始终会帮我们生成一个.在类中只有在没有自己写一个构造函数的前提下,编译器才 会帮我们生成一个默认构造函数.在编译器为结构生成的默认构造函数中,总是将字段设为0,false或者null,这和类是一样的.然而,在自己写的一个 构造函数中(再次提醒,这必须是一个非默认的构造函数),必须自己负责初始化所有字段,编译器不会再帮我们初始化它.这意味着必须在结构的所有非默认构造 函数中显式地初始化所有字段,否则会造成编译时错误.例如,假定把Time换
阅读全文
摘要:来源:http://mcdelfino.blog.51cto.com/2058744/661036值传递, 只是传递副本, 而引用传递, 是传递一个地址~usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication10{classProgram{staticvoidMain(string[]args){intv=42;intr=42;DoWorkVal(v);DoWorkRef(refr);Console.WriteLine("值传递,
阅读全文
摘要:来源:http://mcdelfino.blog.51cto.com/2058744/660711string直接分成char数组, 然后逐个输出来~usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication1{classProgram{staticvoidMain(string[]args){strings=Console.ReadLine();Console.WriteLine("字符----------十进制");fo
阅读全文
摘要:#region Using directivesusing System;using System.Collections.Generic;using System.Text;#endregionnamespace DailyRate{ class Program { static void Main(string[] args) { (new Program()).run(); } public void run() { double dailyRate = read...
阅读全文