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. html的<meta>标签的作用

    <meta>标签包含了页面文档的上下文信息. 主要包含的上下文信息: 1.配置了服务器向浏览器响应时,http协议的head信息,浏览器根据head执行相应操作. 2.对页面的描述信息,便 ...

  2. [水煮 ASP.NET Web API2 方法论](3-6)万能路由

    问题 定义什么样的路由,可以不会受请求参数类型和数量的限制,而被全部捕获? 解决方案 在路由模板中,给参数添加一个"*"前缀,例如 {*param},只要请求的 URL 能够和路由 ...

  3. 炉石传说 C# 开发笔记(BS上线尝试)

    昨天买了一个月的1G 1核的服务器,由于不是新用户,所以没有享受到阿里的6个月免费的优惠. (阿里脑残,为什么不对于续费或者升级免费呢?) 在服务器的通讯上面已经OK了,完全绕过了ASP.NET,就是 ...

  4. 基于吉日嘎底层架构的通用权限管理Web端UI更新:参考DTcms后台界面

    经一周的研究学习,看了国内的H+.HUI等,国外的PaperDashboardPro.Make.Metronic BootStrap等,最终选定用一个轻量的,适合中国人的,来自DTcms的后台管理UI ...

  5. SSH实例(7)

    运行结果. 浏览课程: 添加课程: 还有删除课程,这里就不演示了.

  6. Tigase集群设置

    在两台Linux服务器ddd(IP:10.3.93.212)和tsung213(IP:10.3.93.213)上安装了Tigase,要把这两台服务器组成一个Tigase集群,只需要修改这两台服务器的i ...

  7. 动态加载HTML后使用query修改标签样式

    下面的IMG 标签的宽度从后台返回是10PX,加载完毕后,修改成100PX,注意:拼接的代码在 body标签之后,或则直接在HTML外面增加也可以 <html> <head> ...

  8. Razor语法大全

    本文页面来源地址:http://www.cnblogs.com/dengxinglin/p/3352078.html Razor是基于framewor4以上写的一个开源项目:https://githu ...

  9. Jmeter常用函数之__CSVRead使用

    __CSVRead函数用于对脚本进行参数话,当脚本中不同变量需要不同参数值时,可以考虑__CSVRead函数. 以登录的用户名.密码为例:实际进行压力测试时,需要模拟使用不同的用户并发访问系统,此时需 ...

  10. 1 UML基础

    学习设计模式的过程中,发现相关的作者们都会用UML类图来表示一个模式的整体脉络,这种方式确实直观明了,既能体现宏观思路.又能兼顾实现细节.真的是很妙的工具.在开始正式学习设计模式之前,有必要对UML有 ...