孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

随笔分类 -  C#

上一页 1 2 3 4

摘要:可用is运算符检查是否支持接口,用as运算符转换接口,如: 阅读全文
posted @ 2011-05-04 22:16 孤独的猫 阅读(517) 评论(0) 推荐(0)

摘要:如public class Car : MotorVehicle, IDrivable, ISteerable形式,例如: 阅读全文
posted @ 2011-05-04 22:14 孤独的猫 阅读(178) 评论(0) 推荐(0)

摘要:多个接口间用,号分开即可,如 阅读全文
posted @ 2011-05-04 22:11 孤独的猫 阅读(475) 评论(0) 推荐(0)

摘要:C#可用interface IDrivable实现接口: 阅读全文
posted @ 2011-05-04 22:03 孤独的猫 阅读(340) 评论(0) 推荐(0)

摘要:/* Example7_6.cs illustrates some of the System.Object class methods*/ using System; class Example7_6{ class Program { static void Main(string[] args) { MyStruct st = new MyStruct(); st.X = 50; Console.WriteLine(st.X); Console.ReadLine(); } 阅读全文
posted @ 2011-05-03 20:42 孤独的猫 阅读(303) 评论(0) 推荐(0)

摘要:/* Example7_6.cs illustrates some of the System.Object class methods */ using System; // declare the Car class 阅读全文
posted @ 2011-05-03 20:36 孤独的猫 阅读(350) 评论(0) 推荐(0)

摘要:/* Example6_3.cs illustrates the use of readonly fields */ // declare the Car class public class Car { // declare a readonly field public readonly string make; // declare a static readonly field public static readonly int wheels = 4; // define a constructor public Car(string make) { System.Console.WriteLine("Creating a Car object"); this.make = make; } } 阅读全文
posted @ 2011-05-03 20:32 孤独的猫 阅读(167) 评论(0) 推荐(0)

摘要:要改变参数的值,可以用引用传值方式(使用ref关键字) /* Example5_7.cs illustrates passing parameters by reference */ // declare the Swapper class public class Swapper 阅读全文
posted @ 2011-05-03 20:30 孤独的猫 阅读(198) 评论(0) 推荐(0)

摘要:/* Example4_17.cs illustrates the use of the #undef, #elif, and #else preprocessor directives */ #define DEBUG #undef DEBUG #define PRODUCTION 阅读全文
posted @ 2011-05-03 20:26 孤独的猫 阅读(153) 评论(0) 推荐(0)

摘要:C#中枚举类型用Enum表示 class Example2_10 { enum Planets { Mercury = 1, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto } 阅读全文
posted @ 2011-05-03 20:25 孤独的猫 阅读(127) 评论(0) 推荐(0)

摘要:格式化字符 格式化字符          描述 f或F            格式化浮点数 e或E            用指数计数法格式化数字 p或P            格式化百分数 n或N            用逗号分隔符格式化数字 c或C            格式化本地货币值 阅读全文
posted @ 2011-05-03 20:23 孤独的猫 阅读(252) 评论(0) 推荐(0)

摘要:C#中也有类似于C++的运算符重载,如下例中Rectangel中的+操作 using System; using System.Collections.Generic; using System.Linq; using System.Text; 阅读全文
posted @ 2011-05-03 20:10 孤独的猫 阅读(190) 评论(0) 推荐(0)

摘要:密封类和方法对继承和多态进行限制。在希望别人不能改变代码又希望自己使用时,可以在代码中使用密封的类和方法:使用sealed关键字来表示类或方法为密封 using System; 阅读全文
posted @ 2011-05-03 19:50 孤独的猫 阅读(249) 评论(0) 推荐(0)

摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; 阅读全文
posted @ 2011-05-03 19:45 孤独的猫 阅读(142) 评论(0) 推荐(0)

摘要:int变量可以用ToString方法隐式的转换为一个System.Object对象,这个过程叫包装;一个System.Object也可以转换为一个值变量,这个过程叫解包 阅读全文
posted @ 2011-05-03 19:01 孤独的猫 阅读(168) 评论(0) 推荐(0)

摘要:using System; public class Car 阅读全文
posted @ 2011-05-02 22:15 孤独的猫 阅读(226) 评论(0) 推荐(0)

摘要:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.Win32; 阅读全文
posted @ 2011-04-29 21:45 孤独的猫 阅读(326) 评论(0) 推荐(0)

摘要:C#注册表操作类 阅读全文
posted @ 2011-04-29 14:31 孤独的猫 阅读(347) 评论(0) 推荐(0)

摘要:在VC#中提供了Registry类、RegistryKey类来实现对注册表的操作。 其中Registry类封装了注册表的七个基本主健:   Registry.ClassesRoot 对应于HKEY_CLASSES_ROOT主键   Registry.CurrentUser 对应于HKEY_CURRENT_USER主键   Registry.LocalMachine 对应于 HKEY_LOCAL_MACHINE主键   Registry.User 对应于 HKEY_USER主键   Registry.CurrentConfig 对应于HEKY_CURRENT_CONFIG主键   Registry.DynDa 对应于HKEY_DYN_DATA主键   Registry.PerformanceData 对应于HKEY_PERFORMANCE_DATA主键 阅读全文
posted @ 2011-04-29 14:30 孤独的猫 阅读(309) 评论(0) 推荐(0)

上一页 1 2 3 4