1.结构体里面是否可以有属性?

  可以有属性。实测代码以及截图。

In C#, we can use the following statement to convert a string s to an integer num 124

  A.int num = Convert.ToInt32(s);

  B.int nym = Int32.Parse(s);

  C.int num = s.ToInt();(不可以)

  D.int num = int.Parse(s);(测试可以过)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace Fraction
{
public struct StructTest
{
private int x;
public int X
{
get { return x; }
set { x = value; }
}
public StructTest(int _x)
{
x = _x;
}
}
class Program
{
static void Main(string[] args)
{
StructTest str = new StructTest();
str.X = ;
Console.WriteLine(str.X);
string s = "";
int num1 = Convert.ToInt32(s);
int num2 = Int32.Parse(s);
//int num3 = s.ToInt();
int num4 = int.Parse(s);
Console.WriteLine("num1="+num1);
Console.WriteLine("num2="+num2);
//Console.WriteLine(num3);
Console.WriteLine("num4="+num4);
Console.Read();
}
}
}

  Property 可声明在 class, struct, interface里!

  使用属性的好处:

    允许只读或者只写字段;

    可以在访问时验证字段;

    接口和实现的数据可以不同;

    替换接口中的数据。

  

2.参数传递的方式:按值传递、按引用传递。没有按位置传递、没有按名称传递。

3.LINQ查询:LINQ to Object, LINQ to XML, LINQ to ADO.NET 包括两种独立的技术: LINQ to DataSet 和 LINQ to SQL

对于LINQ to Object可以查询数组等里面的数据;

对于LINQ to SQL可以查询SQL能够查询的表中的数据;

对于LINQ to XML可以查询XML文档的标签等;

对于LINQ to DataSet可以查询DataSet中的数据;

3.委托的形式

  f = delegate(int x){return x + 1;};

  f = x => x+1;

  

测试代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace Lambda
{
class Program
{
static void Main(string[] args)
{
int sum = ;
Func<int, int> f1 = x => * x + ;
Func<int, int, bool> f2 = (x, y) => x > y;
Func<string, int, string> f3 = (x, y) => x.Substring(y);
Func<int, int> f4 = (x) => sum += x;
Action a1 = () => { System.Console.WriteLine("HelloWorld"); };
Action <int> a2 = (x) => { System.Console.WriteLine(x); };
Action <bool> a3 = (x) => { System.Console.WriteLine(x); };
Action<string> a4 = (x) => { System.Console.WriteLine(x); }; for (int i = ; i <= ; i++ )
{
f4(i);
}
a2(sum);
a1();
a2(f1());
a3(f2(, ));
a4(f3("Zhengpengfei", ));
System.Console.Read();
}
}
}

4.内嵌类型可以是类、结构、结构体、枚举、委托

  具体见PPT

5.类与结构体、类与接口、重载(overloading)与重写(overriding)、虚方法与抽象方法、托管代码与非托管代码

  

6.Constants can be declared static (True)

  在C#中const与static不能同时修饰变量;

7.装箱boxing:值类型转换为引用类型;

  拆箱unboxing:引用类型转为值类型。

8.An interface member is implemented or _inherited__from a base class

  接口的成员要么自己定义要么继承自父类。

  接口不能包含常量、字段、操作符、构造函数、析构函数、任何静态成员、方法的实现

9.What is the difference between private assembly and public assembly?

  private assembly只能被一个应用程序使用、保存在应用程序目录中、不要求强命名、无法签名;

  public assembly可以被所用应用程序使用、保存在全局程序集中、必须有一个强命名、可以签名

  另外强命名包括四个部分:Assembly的命名、Assembly的版本号、Assembly的文化属性、Assembly的公钥。

10.Which of the following are correct ways to pass a parameter to a attribute?

1)       By value   2)by reference   3)by position     4)by name

A 1 ,2      B 3,4     C 1,2,3,4     D1,2,3

随机推荐

  1. 【转载】ASP.NET MVC的过滤器

    APS.NET MVC中(以下简称“MVC”)的每一个请求,都会分配给相应的控制器和对应的行为方法去处理,而在这些处理的前前后后如果想再加一些额外的逻辑处理.这时候就用到了过滤器. MVC支持的过滤器 ...

  2. node.js下when.js(Promises/A)的实践

    假设一个业务场景: 通过rss地址,获取rss并保存于文件,rss地址保存于文件中. 完成该场景的业务需要完成3个任务: 1.从文件中读取rss地址. 2.获取rss. 3.保存于文件. 最后将这三个 ...

  3. C#进行Visio二次开发之文件导出及另存Web页面

    在我前面很多关于Visio的开发过程中,介绍了各种Visio的C#开发应用场景,包括对Visio的文档.模具文档.形状.属性数据.各种事件等相关的基础处理,以及Visio本身的整体项目应用,虽然时间过 ...

  4. Web API Filter ActionFilterAttribute 使用

    WebApi 提供两种过滤器的类型: 1.ActionFilterAttribute 2.exceptionFilterAttribute 两个类都是抽象类,ActionFilter 主要实现执行请求 ...

  5. ASP.NET Core 开发-Entity Framework (EF) Core 1.0 Database First

    ASP.NET Core 开发-Entity Framework Core 1.0 Database First,ASP.NET Core 1.0 EF Core操作数据库. Entity Frame ...

  6. C# 表达式学习积累

    /// <summary> /// 读取html里面的body内容(不包括<body>标签) /// </summary> /// <param name=& ...

  7. Java NIO:浅析I/O模型

    也许很多朋友在学习NIO的时候都会感觉有点吃力,对里面的很多概念都感觉不是那么明朗.在进入Java NIO编程之前,我们今天先来讨论一些比较基础的知识:I/O模型.下面本文先从同步和异步的概念 说起, ...

  8. 更改(修改)mysql自动增序列改变从1000开始

    更改(修改)mysql自动增序列改变从1000开始 ************************************************************************** ...

  9. 使用PDF.JS在线查看PDF

    过程简单粗暴. 第一步:下载源码https://github.com/mozilla/pdf.js 第二步:将源码拷贝进项目中,可以新建一个PDFShow文件夹存放代码 第三步:修改viewer.js ...

  10. 【Qt】2.3 使用Qt设计师来创建对话框

    安装完Qt OpenSource之后,在开始菜单目录下会有这几个东西. 其中[Designer]是用来设计窗口界面的程序.所以现在可以使用它来设计一个对话框.在[Qt Creator]中,[设计]这一 ...