C#2
同名的两个类如果在不同的命名空间中,相互之间是不会混淆的。
一个名为TextHello的命名空间中创建一个名为Program的类,引用方法 TextHello.Program
我们常用的Console类存在于System命名空间中,这意味着它的全名为System.Console,但每次输入总显得麻烦,这时你可以用 using System ; 命令来限定要使用的命名空间。在写代码的时候只需要输入 Console即可,免去了总是输入System的麻烦。
C#求数组长度 数组名.Length
- namespace sorter
- {
- public class SelectionSorter //类名
- {
- private int min;
- public void Sort(int[] arr)
- {
- for (int i = 0; i < arr.Length - 1; ++i)
- {
- min = i;
- for (int j = i + 1; j < arr.Length; ++j)
- {
- if (arr[j] < arr[min])
- {
- min = j;
- }
- }
- int t = arr[min];
- arr[min] = arr[i];
- arr[i] = t;
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- int[] arrInt = new int[] { 4, 2, 7, 1, 8, 3, 9, 0, 5, 6 };
- SelectionSorter selSor = new SelectionSorter(); //调用类时 需要清空原先的类
- selSor.Sort(arrInt);
- foreach (int i in arrInt) //提取数组中的整数
- {
- Console.WriteLine(i);
- }
- Console.ReadKey();
- }
- }
- }
int[] Sum = new int[50];
Random rd = new Random();///
// 先用for循环给数组取随机数.
for (int s = 0; s <= Sum.Length - 1; s++) // Sum.Length是数组的一个属性,Length代表数组的长度
{
Sum[s] = rd.Next(100);
}
随机推荐
- Ghost的相关问题
一些和Ghost使用有关的问题,记录在这里. 1,有时候使用ghost恢复,发现最后一步选择驱动器是灰色的,这是因为备份文件有些是用Disk模式,有些使用partition模式,所有恢复的时候如果其中 ...
- kuangbin_ShortPath I (POJ 2240)
本身很简单的spfa判环 TLE了一把是因为没写map(不会) 看着别人的答案临时学了一发发现只是用的话还是挺简单的 (但是绝对别学别人直接命名为m) 800多MS水过 噢对了这题Pending到超时 ...
- [hdu 3605]Escape
这题的做法非常直观,却又非常不直观 先容许我吐一下槽吧~作者你的英语是读到火星上去了喵? 题目大体是说人类要移民,然后有 n 个人, m 个星球 每个人都有 m 个 0 . 1 数码表示他能否移民到该 ...
- 如何给caffe添加新的layer ?
如何给caffe添加新的layer ? 初学caffe难免会遇到这个问题,网上搜来一段看似经典的话, 但是问题来了,貌似新版的caffe并没有上面提到的vision_layer:
- Faster RCNN 运行自己的数据,刚开始正常,后来就报错: Index exceeds matrix dimensions. Error in ori_demo (line 114) boxes_cell{i} = [boxes(:, (1+(i-1)*4):(i*4)), scores(:, i)];
function script_faster_rcnn_demo() close all; clc; clear mex; clear is_valid_handle; % to clear init ...
- Jquery暴力解数独
var arry= new Array(); var nums= new Array(); var snum; function numchain() { snum=0; for(var i=0; ...
- linux下单节点oracle数据库间ogg搭建
环境说明: linux为Linux 2.6.32-573.el6.x86_64 oracle为 11g Enterprise Edition Release 11.2.0.1.0 - 64 ...
- c# 获取 webbrowser 完整 cookie
下面的代码实现的功能确实如标题所言,但要求是获取的是当前进程内的webbrowser,跨进程或引用的ShellWindows对象无效, 哎我本来两种情况都要用,只把前者代码先记下: internal ...
- MVC View中获取Url参数的值
如果url是 /home/index?id=3 直接Request就ok. Razor方法 @Html.ViewContext.RouteData.Values["id"] @Re ...
- 查看 activex 组件的方法
查看 activex 组件的方法 可以使用的工具COMRaider 直接安装 并选择对应的类型即可查看相关的信息,比OLE/COM Object Viewer 简洁方便. 具体的操作如下: 随意选择一 ...