代码改变世界

MEP风管对齐方式

2012-05-02 17:23 by 精诚所至 金石为开, 682 阅读, 0 推荐, 收藏, 编辑
摘要:MEP中为风管分别提供了三种水平和垂直对齐方式。 采用这三种对齐方式的效果,不仅和该处选择的对齐方式有关,还与风管的绘制方向有关。下图所示为将水平对正设定为左时的两种不同效果。上风管为左到右方向绘制,下风管为右到左绘制。一种较为简单的对齐方式为假设你正对着绘制方向,左对齐就是用你左手边那条边线对齐,右对齐就是以你右手边那条边线对齐。上图中,两段风管都是在左手边。 阅读全文

IS运算符

2012-04-27 22:18 by 精诚所至 金石为开, 537 阅读, 0 推荐, 收藏, 编辑
摘要:IS运算符判断类型返回布尔值。using System;namespace aa{ class Checker { public void Check(object param1) { if (param1 is ClassA) Console.WriteLine("Variable can be converted to ClassA."); else Console.WriteLine("Variable can't be converted to ClassA."); if (param1 is IMyInterface) Console. 阅读全文

类和迭代器

2012-04-27 21:41 by 精诚所至 金石为开, 243 阅读, 0 推荐, 收藏, 编辑
摘要:迭代器怎么用。Primes类。using System;using System.Collections;using System.Collections.Generic;using System.Text;namespace aa{ public class Primes { private long min; private long max; public Primes():this (2,100) { } public Primes(long minimum,long maximum) { if(min<2) { min=2; } min=minim... 阅读全文

自定义类和集合

2012-04-27 21:10 by 精诚所至 金石为开, 560 阅读, 0 推荐, 收藏, 编辑
摘要:创建三个自定义类和集合。animal类。using System;namespace a{ public abstract class Animal { protected string name; public string Name { get { return name; } set { name=value; } } public Animal() { name="The animal with no name"; } public Animal (string newName) { name=newName; } pu... 阅读全文

类和结构

2012-04-26 22:19 by 精诚所至 金石为开, 274 阅读, 0 推荐, 收藏, 编辑
摘要:类和结构类似。using System;namespace a{ class MyClass { public int val; } struct myStruct { public int val; } class Program { static void Main(string[] args) { MyClass objectA=new MyClass(); MyClass objectB=objectA; objectA.val=10; objectB.val=20; myStruct structA=new myStruct(); myStruct s... 阅读全文

自定义类

2012-04-26 21:40 by 精诚所至 金石为开, 464 阅读, 0 推荐, 收藏, 编辑
摘要:自定义类。using System;namespace a{ public abstract class MyBase { } internal class MyClass:MyBase { } public interface IMyBaseInterface { } internal interface IMyBaseInterface2 { } internal interface IMyInterface:IMyBaseInterface,IMyBaseInterface2 { } internal sealed class MyComplexClass:MyClass,IMyInte 阅读全文

抛出异常

2012-04-25 22:19 by 精诚所至 金石为开, 247 阅读, 0 推荐, 收藏, 编辑
摘要:using System;using System.Collections.Generic;using System.Text;using System.Diagnostics;namespace a{ class Program { static string[] eTypes={"none","simple","index","nested index"}; static void Main(string[] args) { foreach (string eType in eTypes) { try { Co 阅读全文

使用程序调试输出窗口

2012-04-25 21:32 by 精诚所至 金石为开, 538 阅读, 0 推荐, 收藏, 编辑
摘要:程序输出窗口用来对程序运行过程进行监控。using System;using System.Collections.Generic;using System.Text;using System.Diagnostics;namespace a{ class Program { static void Main(string[] args) { int[] textArray={4,7,4,2,7,3,7,8,3,9,1,9}; int[] maxValIndices; int maxVal= Maxima(textArray,out maxValIndices); Conso... 阅读全文

使用委托调用函数

2012-04-25 10:24 by 精诚所至 金石为开, 638 阅读, 0 推荐, 收藏, 编辑
摘要:使用委托调用函数。using System;namespace a{ class Program { delegate double ProcessDelegate(double param1,double param2); static double Multiply(double param1,double param2) { return param1*param2; } static double Divide(double param1,double param2) { return param1/param2; } static void Main(stri... 阅读全文

全局参数

2012-04-25 09:56 by 精诚所至 金石为开, 298 阅读, 0 推荐, 收藏, 编辑
摘要:使用全局参数和局部参数能达到一样的目的。using System;namespace a{ class Program { static void showDouble(ref int val) { val*=2; Console.WriteLine("val doubled={0}",val); } static void Main(string[] args) { int val=5; Console.WriteLine("val ={0}",val); showDouble(ref val); Console.WriteLine("val 阅读全文

函数作用域的示例

2012-04-25 09:35 by 精诚所至 金石为开, 161 阅读, 0 推荐, 收藏, 编辑
摘要:函数只能在其定义的代码块中使用。using System;namespace a{ class Program { static void Write() { string myString ="String defined in Write()"; Console.WriteLine("Now in Write()"); Console.WriteLine("myString={0}",myString); } static void Main(string[] args) { string myString="Strin 阅读全文

带参数的函数返回数组之和

2012-04-25 09:22 by 精诚所至 金石为开, 259 阅读, 0 推荐, 收藏, 编辑
摘要:带参数的函数返回数组之和。using System;namespace a{ class Program { static int MaxValue(int[] intArray) { int maxVal=intArray[0]; for(int i=1;i<intArray.Length;i++) { if(intArray[i]>maxVal) maxVal=intArray[i]; } return maxVal; } static int SumVals(params int[] vals) { int sum = 0; forea... 阅读全文

带函数的参数返回函数的最大值

2012-04-25 09:10 by 精诚所至 金石为开, 592 阅读, 0 推荐, 收藏, 编辑
摘要:该示例用冒泡排序法返回数值中的最大值,利用带参数的函数。using System;namespace a{ class Program { static int MaxValue(int[] intArray) { int maxVal=intArray[0]; for(int i=1;i<intArray.Length;i++) { if(intArray[i]>maxVal) maxVal=intArray[i]; } return maxVal; } static void Main(string[] args) { int[] myArr... 阅读全文

创建函数和引用函数

2012-04-24 22:46 by 精诚所至 金石为开, 181 阅读, 0 推荐, 收藏, 编辑
摘要:简单的例子,输出一句话。using System;namespace a{ class Program { static void Write() { Console.WriteLine("Text output from function."); } public static void Main(string[] args) { Write(); Console.ReadKey(); } }} 阅读全文

字符串操作

2012-04-24 22:34 by 精诚所至 金石为开, 158 阅读, 0 推荐, 收藏, 编辑
摘要:本示例将一串字符串以空格键分割成数组元素。using System;namespace a{ class Program { public static void Main(string[] args) { string myString ="This is a test."; char[] separator={' '}; string[] myWords; myWords=myString.Split(separator); foreach (string word in myWords) { Console.WriteLine("{0}&qu 阅读全文
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 51 下一页