//错误的程序
using System;
class Test
{
unsafe static void WriteLocations(byte[]arr)
{
fixed(byte*p_arr=arr)
{
byte* p_elem = p_arr;
for(int i=0;i<arr.Length;i++)
byte value=*p_elem;
string addr=int.Format((int)p_elem,"x");
Console.WriteLine("arr[{0}]at0x{1}is{2}",i,addr,value);
p_elem++;
}
}
}
static void Main()
{
byte[]Array=new byte[]{1,2,3,4,5};
WriteLocations(arr);
}
static void Main()
{
F();
G();
{
H();
I();
}
} static void Main(String[]args)
{
if(args.Length==0)
goto done;
Console.WriteLine(args.Length);
done:
Console.WriteLine("Done");
} static void Main()
{
const float pi=3.14;
const int r=123;
Console.WriteLine(pi*i*i);
} static void Main()
{
int a;
int b=2,c=3;
a=1;
Console.WriteLine(a+b+c);
} static int F
using System;
class MyClass
{
public MyClass()
{
Console.WriteLine("Constructor");
}
public MyClass(int value)
{
MyField = value;
Console.WriteLine("Destructor");
}
~MyClass()
{
Console.WriteLine("Destructor");
}
public const int MyConst = 12;
public int MyField = 34;
public void MyMethod()
{
Console.WriteLine("MyClass.MyMethod");
}
public int Myproperty()
{
get{
return MyField;
}
set{
MyField=value;
}
}
public int this[int index]{
get
{
return 0;
}
set
{
Console.WriteLine("this[{0}]{1}", index, value);
}
}
public event EventHandler MyEvent;
public static MyClass operator+(MyClass a,MyClass b)
{
return new MyClass(a.MyField + b.MyField);
}
internal class MyNestedClass { } } class Constans
{
public const int A = 1;
public const int B = A + 1;
} class Test
{
static void Main()
{
Console.WriteLine("{0},{1}", Constans.A, Constans.B);
}
} //Fields
class Color
{
internal ushort redpart;
internal ushort bluepart;
internal ushort greenpart;
public Color(ushort red,ushort blue,ushort green)
{
redpart = red;
bluepart = blue;
greenpart = green;
}
} class Color
{
public static Color Red = new Color(0XFF, 0, 0);
public static Color Blue = new Color(0, 0XFF, 0);
public static Color Green = new Color(0, 0, 0XFF);
public static Color While = new Color(0, 0, 0);
}
using System;
class Point
{
public double x, y;
public Point(){
this.x=0;
this.y=0;
}
public Point(double x,double y)
{
this.x = x;
this.y = y;
}
public static double Distance(Point a,Point b)
{
double xdiff = a.x - b.x;
double ydiff = a.y - b.y;
return Math.Sqrt(xdiff * xdiff + ydiff * ydiff);
}
public override string ToString()
{
return string.Format("{0},{1}",x,y);
}
}
class Test
{
static void Main()
{
Point a = new Point();
Point b = new Point(3, 4);
double d = Point.Distance(a, b);
Console.WriteLine("Distance from {0} to {1} is {2}", a, b, d);
}
}
using System;
class Point
{
public double x, y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
~Point()
{
Console.WriteLine("Destructed {0}", this);
}
public override string ToString()
{
return string.Format("{0},{1}",x,y);
}
}
using System;
class Test
{
static void Main()
{
Type type = typedef(Class1);
object[] arr = type.GetCustomAttributes(typeof(HelpAttribute));
if (arr.Length == 0)
Console.WriteLine("Class1 has no Help attribute.");
else
{
HelpAttribute ha = (HelpAttribute)arr[0];
Console.WriteLine("Ur1={0},Topic={1}", ha.Ur1, ha.Topic);
}
}
}
using System;
class Test
{
static void Main()
{
Type type = typedef(Class1);
object[] arr = type.GetCustomAttributes(typeof(HelpAttribute));
if (arr.Length == 0)
Console.WriteLine("Class1 has no Help attribute.");
else
{
HelpAttribute ha = (HelpAttribute)arr[0];
Console.WriteLine("Ur1={0},Topic={1}", ha.Ur1, ha.Topic);
}
}
}

随机推荐

  1. 《手把手教你》系列技巧篇(二十九)-java+ selenium自动化测试- Actions的相关操作上篇(详解教程)

    1.简介 有些测试场景或者事件,Selenium根本就没有直接提供方法去操作,而且也不可能把各种测试场景都全面覆盖提供方法去操作.比如:就像鼠标悬停,一般测试场景鼠标悬停分两种常见,一种是鼠标悬停在某 ...

  2. 使用 grpcurl 通过命令行访问 gRPC 服务

    原文链接: 使用 grpcurl 通过命令行访问 gRPC 服务 一般情况下测试 gRPC 服务,都是通过客户端来直接请求服务端.如果客户端还没准备好的话,也可以使用 BloomRPC 这样的 GUI ...

  3. 在IDEA中创建SpringBoot项目01

    1.选择创建项目 2.填写项目信息 3. 4. 5.Finish后会下载,之后生成目录结构: 6.在自己的包目录结构下添加了Controllr和Entiy测试项目: Controller: 1 pac ...

  4. 舌头算法的C++实现

    观察生活,我们不难发现,吃饭的时候,有时候左边的东西会到右边来,这是为什么呢?就是舌头的作用了. 下面的代码将模拟舌头的运动: #include <iostream> #include & ...

  5. 《JavaScript DOM编程艺术》:innerHTML

    来源:第七章 动态创建标记 innerHTML: 1.HTML页面建立空白div: <div id="testdiv"> </div> <script ...

  6. 【数据结构与算法Python版学习笔记】图——基本概念及相关术语

    概念 图Graph是比树更为一般的结构, 也是由节点和边构成 实际上树是一种具有特殊性质的图 图可以用来表示现实世界中很多有意思的事物,包括道路系统.城市之间的航班.互联网的连接,甚至是计算机专业的一 ...

  7. Redis:学习笔记-01

    Redis:学习笔记-01 该部分内容,参考了 bilibili 上讲解 Redis 中,观看数最多的课程 Redis最新超详细版教程通俗易懂,来自 UP主 遇见狂神说 1. Redis入门 2.1 ...

  8. Java编程开发学习路线图(附所有免费课程+在线自测)

    转自  https://yq.aliyun.com/articles/134286?spm=5176.100239.0.0.1UfveS 摘要: 长期以来,Java一直占据TIOBE编程语言排行版第一 ...

  9. Django+Vue跨域配置与经验

    一.原理 同源?同源策略? 同源的定义是:两个页面的协议.端口和域名都相同 同源的例子: 不同源的例子: 同源策略SOP(Same origin policy)是一种浏览器约定,它是浏览器最核心也最基 ...

  10. mdev 响应热插拔事件

    热插拔事件是从内核空间发送到用户空间的通知,一般这时候系统配置出现了变化,比如插入/移除耳机,插入/移除SD卡或者USB存储设备等. 热插拔事件默认会调用/sbin/hotplug来加载驱动程序,创建 ...