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怎样引用你的model

    在视图中,引用model,并绑定.有2种情况,一是数据集,另一个是单个model. 实现之前,有准备一个数据吧. 创建一个model: source code: namespace Insus.NET ...

  2. Web API应用架构在Winform混合框架中的应用(5)--系统级别字典和公司级别字典并存的处理方式

    在我这个系列中,我主要以我正在开发的云会员管理系统为例进行介绍Web API的应用,由于云会员的数据设计是支持多个商家公司,而每个公司又可以包含多个店铺的,因此一些字典型的数据需要考虑这方面的不同.如 ...

  3. bootstrap学习笔记系列4------bootstrap按钮

    按钮标签 在<a>,<button>或input元素上使用按钮class.但是为了避免跨浏览器的不一致性,建议使用<button>标签. <!DOCTYPE ...

  4. ASP.NET MVC 网站开发总结(三) ——图片截图上传

    本着简洁直接,我们就直奔主题吧,这里需要使用到一个网页在线截图插件imgareaselect(请自行下载). 前台页面: <!DOCTYPE html> <html> < ...

  5. html5学习笔记4--API Range对象(一)

    Range对象基本用法 效果图如下(在谷歌浏览器下的展示)

  6. C#中WinForm窗体事件的执行次序

    C#中WinForm窗体事件的执行次序如下: 当 Windows Form 应用程序启动时,会以下列顺序引发主要表单的启动事件:        System.Windows.Forms.Control ...

  7. IOS 2D游戏开发框架 SpriteKit-->续(postion,锚点,游戏滚动场景)

    一. Postion 这里的postion和app开发中的layer.postion是一样的,postion的值代表该视图在父节点中的相对位置, 比如一个试图的父节点是self.view, 这里我们想 ...

  8. Scalaz(10)- Monad:就是一种函数式编程模式-a design pattern

    Monad typeclass不是一种类型,而是一种程序设计模式(design pattern),是泛函编程中最重要的编程概念,因而很多行内人把FP又称为Monadic Programming.这其中 ...

  9. C# Unicode编码

    为了避免在浏览器中传输数据的时候出现中文乱码,我们可以将内容进行URL编码,当然也可以将内容进行UNICODE编码.将汉字进行UNICODE编码,如:"王"编码后就成了" ...

  10. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解决办法

    09:00:30.307 [http-8080-6] ERROR org.hibernate.transaction.JDBCTransaction -JDBC begin failed com.my ...