C#练习2
using System;
class Class1
{
public int vlaue = 0;
}
class Test
{
static void Main()
{
int v1 = 0;
int v2 = v1;
v2 = 123;
Class1 r1 = new Class1();
Class1 r2 = r1;
r2.vlaue = 123;
Console.WriteLine("Value:{0},{1}", v1, v2);
Console.WriteLine("Refs:{0},{1}", r1.vlaue, r2.vlaue);
}
}
using System;
public enum Color
{
Red,Blue,Green
}
public struct Point
{
public int x,y;
}
public interface IBase
{
void F();
}
public interface IDerived:IBase
{
void G();
}
public class A
{
protected void H()
{
Console.WriteLine("A.H");
}
}
public class B:A,IDerived
{
public void F()
{
Console.WriteLine("B.F,implementation of IDerived.F");
}
public void G()
{
Console.WriteLine("B.G,implementation of IDerived.G");
}
override protected void H()
{
Console.WriteLine("B.H,override of A.H");
}
}
//public delegate void EmptyDelegate();
using System;
class Test
{
static void Main()
{
string s = "Test";
string t = string.Copy(s);
Console.WriteLine(s == t);
Console.WriteLine((object)s == (object)t);
}
}
using System;
class Test
{
static void Main()
{
int intvalue = 123;
long longvalue = intvalue;
Console.WriteLine("(long){0}={1}", intvalue, longvalue);
}
}
using System;
class Test
{
static void Main()
{
long longValue = Int64.MaxValue;
int intValue = (int)longValue;
Console.WriteLine("(int){0}={1}", longValue, intValue);
}
}
using System;
class Test
{
static void Main()
{
int[] arr = new int[5];
for (int i = 0; i < arr.Length; i++)
arr[i] = i * i;
for (int i = 0; i < arr.Length; i++)
Console.WriteLine("arr[{0}]={1}", i, arr[i]);
}
}
using System;
class Test
{
static void Main()
{
int[] a1;
int[,] a2;
int[, ,] a3;
int[][] j2;
int[][][] j3;
}
}
using System;
class Test
{
static void Main()
{
int[] a1 = new int[] { 1, 2, 3 };
int[,] a2 = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } };
int[, ,] a3 = new int[10, 20, 30];
int[][] j2 = new int[3][];
j2[0] = new int[] { 1, 2, 3 };
j2[1] = new int[] { 1, 2, 3, 4, 5, 6 };
j2[2] = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
}
}
using System;
class Test
{
static void Main()
{
Console.WriteLine(3.ToString());
}
}
using System;
class Test
{
static void Main()
{
int i = 123;
object o = i;
int j = (int)o;
Console.WriteLine(i);
Console.WriteLine(o);
}
}
using System;
class Test
{
static void F(int p)
{
Console.WriteLine("p={0}", p);
p++;
}
static void Main()
{
int a = 1;
Console.WriteLine("pre:a={0}",a);
F(a);
Console.WriteLine("post:a={0}",a);
}
}
using System;
class Test
{
static void Swap(ref int a,ref int b)
{
int t = a;
a = b;
b = t;
}
static void Main()
{
int x = 1;
int y = 2;
Console.WriteLine("pre:x={0},y={1}", x, y);
Swap(ref x, ref y);
Console.WriteLine("post:x={0},y={1}", x, y);
}
}
随机推荐
- 易华录 X ShardingSphere|葫芦 App 后台数据处理的逻辑捷径
"ShardingSphere 大大简化了分库分表的开发和维护工作,对于业务的快速上线起到了非常大的支撑作用,保守估计 ShardingSphere 至少为我们节省了 4 个月的研发成本.& ...
- Java基础之(十一):方法
Java方法详解 何谓方法(了解) System.out.println() // 类 对象 方法 方法是语句的集合,它们在一起执行一个功能. 方法是解决一类问题的步骤的有序集合 方法包含于类或对象中 ...
- 定制input元素
定制input元素 input元素可以用来生成一个供用户输入数据的简单文本框.其缺点在于用户在其中输入什么值都可以.有时这还不错,但是有时设计者可能希望让用户输入特定类型的数据.在后一种情况下,可以对 ...
- python中return的返回和执行
1 打印函数名和打印函数的执行过程的区别 例子1.1 def a(): print(111) print(a) # 打印a函数的内存地址,不会对a函数有影响,a函数不会执行 print(a()) # ...
- java实现责任链模式的小demo
//一个请假请求 public class LeaveRequest { private int leaveDays; private String name; public void leave() ...
- 2021能源PWN wp
babyshellcode 这题考无write泄露,write被沙盒禁用时,可以考虑延时盲注的方式获得flag,此exp可作为此类型题目模版,只需要修改部分参数即可,详细见注释 from pwn im ...
- 【c++ Prime 学习笔记】第5章 语句
C++提供了一组控制流语句,包括条件执行语句.循环语句.跳转语句. 5.1 简单语句 空语句 ; ,最简单的语句 别漏写分号,也别多写 while(cin>>s && s! ...
- vue3.x全局$toast、$message、$loading等js插件
有时候我们需要使用一些类似toast,messge.loading这些跟js交互很频繁的插件,vue3.x这类插件的定义跟vue2.x插件稍大,而且相对变得复杂了一点点. 第一种.需要时创建,用完移除 ...
- airtest keyevent 按键速查表
- kivy浮点布局
from kivy.app import App from kivy.uix.floatlayout import FloatLayout class FloatLayoutWidget(FloatL ...