上一页 1 ··· 7 8 9 10 11
摘要: 【问】1、特定就是属性吗?2、以下结果输出什么?[C#]namespace Anytao.net{ class MainClass { static void Main() { MainClass aa = new MainClass(); aa.CannotRun(); Console.ReadKey(); } [Test("参数")] public void CannotRun() { Console.WriteLine("执行CannotRun()方法"); } [AttributeUsag... 阅读全文
posted @ 2011-11-16 15:21 Serviceboy 阅读(785) 评论(0) 推荐(0) 编辑
摘要: 【问】在C#和Visual Basic的转换中,以下一些转换的用法和区别是什么呢?[C#]long num = 12;int n = (int)num;int m = Convert.ToInt32(num);[VB.NET]Dim num As Long = 12Dim n As Integer = numn = CInt(num)n= CType(num,Integer)n = Convert.ToInt32(num)【错误回答】没有区别,因为运行了之后都可以正常转化。【正解】光从运行结果来看当然是毫无区别,因为题目所给出的仅仅是一部分的例子,不是全部。许多初学者容易产生“以偏概全”的错误 阅读全文
posted @ 2011-11-01 16:28 Serviceboy 阅读(907) 评论(0) 推荐(2) 编辑
摘要: 【问】以下代码问题出在哪里呢?[C#]namespace Test{ public class MainTest { public static void Main(String[] args) { Object obj = new string(new char[]{‘a’,’b’,’c’}); List<Object> objects = new List<string>(); } ... 阅读全文
posted @ 2011-10-29 10:48 Serviceboy 阅读(1560) 评论(4) 推荐(0) 编辑
摘要: 【问】假设有这样一段代码[C#]namespace MyTest{public interface I{void Change(int x, int y);}public struct Point:I{public int X { get; set; }public int Y { get; set; }public override string ToString(){return X+","+Y;}public void Change(int x, int y){X=x;Y=y;}}public class Program{static void Main(string 阅读全文
posted @ 2011-10-25 13:02 Serviceboy 阅读(674) 评论(0) 推荐(1) 编辑
上一页 1 ··· 7 8 9 10 11