同名的两个类如果在不同的命名空间中,相互之间是不会混淆的。

一个名为TextHello的命名空间中创建一个名为Program的类,引用方法 TextHello.Program

我们常用的Console类存在于System命名空间中,这意味着它的全名为System.Console,但每次输入总显得麻烦,这时你可以用 using System ;  命令来限定要使用的命名空间。在写代码的时候只需要输入 Console即可,免去了总是输入System的麻烦。

C#求数组长度        数组名.Length

  1. namespace sorter
  2. {
  3. public class SelectionSorter   //类名
  4. {
  5. private int min;
  6. public void Sort(int[] arr)
  7. {
  8. for (int i = 0; i < arr.Length - 1; ++i)
  9. {
  10. min = i;
  11. for (int j = i + 1; j < arr.Length; ++j)
  12. {
  13. if (arr[j] < arr[min])
  14. {
  15. min = j;
  16. }
  17. }
  18. int t = arr[min];
  19. arr[min] = arr[i];
  20. arr[i] = t;
  21. }
  22. }
  23. }
  24. class Program
  25. {
  26. static void Main(string[] args)
  27. {
  28. int[] arrInt = new int[] { 4, 2, 7, 1, 8, 3, 9, 0, 5, 6 };
  29. SelectionSorter selSor = new SelectionSorter();   //调用类时 需要清空原先的类
  30. selSor.Sort(arrInt);
  31. foreach (int i in arrInt)    //提取数组中的整数
  32. {
  33. Console.WriteLine(i);
  34. }
  35. Console.ReadKey();
  36. }
  37. }
  38. }

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);
}

随机推荐

  1. Ghost的相关问题

    一些和Ghost使用有关的问题,记录在这里. 1,有时候使用ghost恢复,发现最后一步选择驱动器是灰色的,这是因为备份文件有些是用Disk模式,有些使用partition模式,所有恢复的时候如果其中 ...

  2. kuangbin_ShortPath I (POJ 2240)

    本身很简单的spfa判环 TLE了一把是因为没写map(不会) 看着别人的答案临时学了一发发现只是用的话还是挺简单的 (但是绝对别学别人直接命名为m) 800多MS水过 噢对了这题Pending到超时 ...

  3. [hdu 3605]Escape

    这题的做法非常直观,却又非常不直观 先容许我吐一下槽吧~作者你的英语是读到火星上去了喵? 题目大体是说人类要移民,然后有 n 个人, m 个星球 每个人都有 m 个 0 . 1 数码表示他能否移民到该 ...

  4. 如何给caffe添加新的layer ?

    如何给caffe添加新的layer ? 初学caffe难免会遇到这个问题,网上搜来一段看似经典的话, 但是问题来了,貌似新版的caffe并没有上面提到的vision_layer:

  5. 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 ...

  6. Jquery暴力解数独

      var arry= new Array(); var nums= new Array(); var snum; function numchain() { snum=0; for(var i=0; ...

  7. linux下单节点oracle数据库间ogg搭建

    环境说明:   linux为Linux 2.6.32-573.el6.x86_64     oracle为 11g Enterprise Edition Release 11.2.0.1.0 - 64 ...

  8. c# 获取 webbrowser 完整 cookie

    下面的代码实现的功能确实如标题所言,但要求是获取的是当前进程内的webbrowser,跨进程或引用的ShellWindows对象无效, 哎我本来两种情况都要用,只把前者代码先记下: internal ...

  9. MVC View中获取Url参数的值

    如果url是 /home/index?id=3 直接Request就ok. Razor方法 @Html.ViewContext.RouteData.Values["id"] @Re ...

  10. 查看 activex 组件的方法

    查看 activex 组件的方法 可以使用的工具COMRaider 直接安装 并选择对应的类型即可查看相关的信息,比OLE/COM Object Viewer 简洁方便. 具体的操作如下: 随意选择一 ...