//错误的程序
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. Redis缓存穿透、缓存击穿、缓存雪崩的介绍及其解决方案

    首先,来画一张图了解下缓存处理的流程 一.缓存穿透 描述: 缓存穿透是指缓存和数据库中都没有的数据,而用户不断发起请求查询该数据,导致数据库压力过大. 解决方案: 1.接口校验 如鉴权校验.数据合法性 ...

  2. 山顶点提取(ArcPy实现)

    一.背景 山顶点指哪些在特定邻域分析范围内,该点都比周围点高的区域.山顶点是地形的重要特征点,它的分布与密度反映了地貌的发育特征,同时也制约着地貌发育.因此,如何基于DEM数据正确有效的提取山顶点,在 ...

  3. K12教培从业者转型指南 换个赛道依然可以再创辉煌

    随着"双减"政策的落地,属于K12教培机构的时代逐渐拉上帷幕,面对机会不再的K12教培行业,约70万机构和近千万的从业人员面临转型问题.压力之下,留下或离开?对广大K12教培机构从 ...

  4. 【转】对于编译程序时出现“Deprecated declaration ultrasonic_Init - give arg types”的解决办法

    编译程序时出现"Deprecated declaration ultrasonic_Init - give arg types"中文释义:给定函数的参数的类型过时, 解决办法: 在 ...

  5. Python语法1

    变量 命名规则 变量名必须是大小写英文字母.数字或下划线 _ 的组合,不能用数字开头,并且对大小写敏感 变量赋值 同一变量可以反复赋值,而且可以是不同类型的变量 i=2; i="name&q ...

  6. kivy Label标记文本

    from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.lang import Builder # 注意 ...

  7. OO面向对象第三次作业总结

    面向对象第三次作业总结 一.JML基础梳理及工具链 注释结构 行注释://@annotation 块注释:/*@ annotation @*/ 两种注释都是放在被注释部分上面. 常见表达式 原子表达式 ...

  8. PCB电路板元器件布局的一般原则*(转)

    PCB电路板元器件布局的一般原则: 设计人员在PCB电路板布局过程中需要遵循的一般原则如下. (1)元器件最好单面放置.如果需要双面放置元器件,在底层(Bottom Layer)放置插针式元器件, ) ...

  9. 小白学习C语言必背的18个经典程序

    1./*输出9*9口诀.共9行9列,i控制行,j控制列.*/ #include "stdio.h" main() {int i,j,result; for (i=1;i<10 ...

  10. 万维网www与HTTP协议

    文章转自:https://blog.csdn.net/weixin_43914604/article/details/105901440 学习课程:<2019王道考研计算机网络> 学习目的 ...