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);
}
}
随机推荐
- 终端进程启动失败: shell 可执行文件“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”的路径不存在。
因为某些原因重新安装1了vscode 和node 遇到了两个棘手的问题 ctrl + ~ 打开终端提示 " 终端进程启动失败: shell 可执行文件"C:\Windows\S ...
- gcc、g++、gdb安装
Windows安装 有闲工夫在Windows上安装g++/gcc/gdb,还不如装个虚拟机安装Linux,在Linux上安装 但是我还是要讲的 首先,需要安装MinGW,MinGW,是Minimali ...
- 题解 「SCOI2016」萌萌哒
link Description 一个长度为 $ n $ 的大数,用 $ S_1S_2S_3 \ldots S_n $表示,其中 $ S_i $ 表示数的第 $ i $ 位,$ S_1 $ 是数的最高 ...
- CVPR2021提出的一些新数据集汇总
前言 在<论文创新的常见思路总结>(点击标题阅读)一文中,提到过一些新的数据集或者新方向比较容易出论文.因此纠结于选择课题方向的读者可以考虑以下几个新方向.文末附相关论文获取方式. ...
- Oil Deposits 新年特辑篇
链接:E - Oil Deposits 题目: The GeoSurvComp geologic survey company is responsible for detecting undergr ...
- FastAPI 学习之路(二十七)安全校验
你写API接口肯定你是希望是有权限的人才能访问,没有权限的人是不能访问的,那么我们应该如何去处理呢,我们可以用的验证方式有很多,我们这次分享的是用:OAuth2来认证.那么我们看下,需要怎么才能实现呢 ...
- LuckySheet一款在线Excel使用心得
1.LuckySheet简介 Luckysheet ,是一款国产的纯JS实现的类似excel的在线表格,功能强大.配置简单.完全开源. 开源地址 https://gitee.com/mengshuke ...
- C++ 类继承 笔记(初步)
本节内容源于对C++ primer第13章的学习,这本书把C++的原理将得明明白白.网上的博客往往讲得一头雾水.到头来还不如看原书本. 问题 首先给出一题: #include<stdio.h&g ...
- python 工具箱
strip() 方法可以从字符串去除不想要的空白符. print() BIF的file参数控制将数据发送/保存到哪里. finally组总会执行,而不论try/except语句中出现什么异常. 会向e ...
- 极速上手 VUE 3 —— teleport传送门组件
一.teleport 介绍 teleport 传送门组件,提供一种简洁的方式,可以指定它里面的内容的父元素.通俗易懂地讲,就是 teleport 中的内容允许我们控制在任意的DOM中,使用简单. 使用 ...