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

一个名为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. Python爬虫学习笔记——豆瓣登陆(三)

    之前是不会想到登陆一个豆瓣会需要写三次博客,修改三次代码的. 本来昨天上午之前的代码用的挺好的,下午时候,我重新注册了一个号,怕豆瓣大号被封,想用小号爬,然后就开始出问题了,发现无法模拟登陆豆瓣了,开 ...

  2. some knowledge of maven {maven实战}

    maven是跨平台的,不仅是一个构建工具,也是一个可以管理依赖的工具.它最大化的消除了构件的重复,并且提供了中央仓库,能帮我们自动下载构件.------------------------------ ...

  3. 常见半监督方法 (SSL) 代码总结

    经典以及最新的半监督方法 (SSL) 代码总结 最近因为做实验需要,收集了一些半监督方法的代码,列出了一个清单: 1. NIPS 2015 Semi-Supervised Learning with ...

  4. .bss 段 block started symbol

    一个英文缩写 cvs = concurrent version system cli = common language infrastructure

  5. Processor Speculative & pipeline

    https://en.wikipedia.org/wiki/Instruction-level_parallelism https://en.wikipedia.org/wiki/Instructio ...

  6. 转载:javascript 拖拽排序,简洁示例备忘

    转载自:http://blog.csdn.net/wang4978/article/details/6721157 <html> <head> <title>拖动行 ...

  7. 安装max plugin wizard

    参考:http://liweizhaolili.blog.163.com/blog/static/162307442013117731953/

  8. 解决Oracle 11g在用EXP导出时,空表不能导出

    实践结论可行,看"2.解决办法" 一.问题原因:     11G中有个新特性,当表无数据时,不分配segment,以节省空间     1.insert一行,再rollback就产生 ...

  9. selenium+python自动化之元素定位

    自动化按步骤拆分的话,可以分为四步操作:定位元素,操作元素,获取返回结果,断言(返回结果与期望结果是否一致),最后自动出测试报告.本篇接下来讲基本的八种元素定位方法.说的通俗一点,就是教大家找对象. ...

  10. 数据库连接工具类 数据库连接工具类——仅仅获得连接对象 ConnDB.java

    package com.util; import java.sql.Connection; import java.sql.DriverManager; /** * 数据库连接工具类——仅仅获得连接对 ...