before 2009.7.16

来源:互联网 发布:古北水镇 知乎 编辑:程序博客网 时间:2024/05/22 12:27

2009.5.7

根据类的名字(变量)来new 一个对象

Type RuleClassType = Type.GetType(RuleClassNameStr, true, true);

object RuleObject = Activator.CreateInstance(RuleClassType);

 

 IRule RuleInstace = (IRule)RuleObject;

 RuleQueue.Enqueue(RuleInstace);

 

 

2009.5.11

public class TDWord:AbstactTDCommon

abstract class AbstactTDCommon

Error         1       Inconsistent accessibility: base class 'CheckRuleAutoTool.AbstactTDCommon' is less accessible than class 'CheckRuleAutoTool.TDWord'

解决:去掉 public, public class TDWord:AbstactTDCommon

,或者public abstract class AbstactTDCommon

 

 

Struct base{}

Class zhongjie = new base();  

Function(ref zhongjie)  //     zhongjie 将不会改变 struct 就是值传递,想要引用改变就要改成class

 

2009-5-19

string[] SecNo = new string[7];

            string oneword;

            char[] separtor = { ',' };

            SecNo = sectionNO.Split(separtor, 7);

 

Split 之后 SecNo 数组的大小改变了三

 

                      打开多个文件:

 

 openFileDialog1.Multiselect=true;  
  foreach(string   strFilename   in   openFileDialog1.FileNames)  
  {  
  MessageBox.Show(strFilename);

  }

 

 

2009-5-20   Dictionary<string,string> dic = new Dictionary<string,string>();

 

 

 

2009-5-25

Dictionary<string, int> KeyWordLoactionDic = new Dictionary<string, int>();

 int ParaHeading = Program.TDDoc.GetHeading(SectionStart);

 int OffSet = ParagraphContext.IndexOf(KeyWordList[0]);

 

   for (int i = 0; i < KeyWordList.Length; i++)

     {

             KeyWordLoactionDic.Add(KeyWordList[i], ParaHeading + OffSet);

             OffSet = OffSet + KeyWordList[i].Length + 1;

      }

 

 

Comment 的范围总是不对

 

原因是()-- 新加的  需要占用一个字符

 

   KeyWordLoactionDic.TryGetValue(KeyWordList[index], out CommentBegin);

                                 CommentBegin = CommentBegin + CommentCount;

                                 CommentEnd = CommentBegin + KeyWordList[index].Length;

                                 RuleCallBack(sender, comments);

                                 CommentCount++;

 

2009-5-27

 

RefOut关键字的区别:

 

 

 

使用Ref型参数时,传入的参数必须先被初始化。而Out则不需要,对Out而言,就必须在方法中对其完成初始化

 

 

首先:两者都是按地址传递的,使用后都将改变原来的数值。很多人在论坛上解释说out是按数值传递,是错误的。简单的测试后可以知道out使用也能改变数值的,所以肯定是按照地址传递的。

其次:ref可以把参数的数值传递进函数,但是out是要把参数清空,就是说你无法把一个数值从out传递进去的,out进去后,参数的数值为空,所以你必须初始化一次。这个就是两个的区别,或者说就像有的网友说的,ref是有进有出,out是只出不进。经典!!!

 

 

 

Out更适合用在需要Return多个返回值的地方,而Ref则用在需要被调用的方法修改调用者的引用的时

 

2009-6-9:

String[] newArray = new string[50];

 

删除数组中重复的元素 newArray = newArray.Distinct().ToArray();

String object has no distinct function.

 

//delete the same word

List<string> wordList = new List<string>();

 IEnumerable<string> distinctKeyWord = wordList.Distinct<string>();

                        wordList = distinctKeyWord.ToList();

 

2009/6/30

首先推荐用 范型 List<T>   

ArraryList 有装箱拆箱的操作 object,

 

 

深度拷贝,浅拷贝

 

  keyWordLoactionDic.TryGetValue(wordList[index], out range);

返回来的 range 是浅拷贝, 是对原对象的引用,

 

 

keyWordLoactionDic.TryGetValue(wordList[index], out range);

  CommentRange newRange = (CommentRange)range.Clone();

                                      

 

实现Clone() function to deep copy.

深度拷贝是一个全新的对象, 对其进行修改不会影响原来的对象,

 

 

2009/7/6

 

for(int   j=i+1;j<str1.Length+str2.Length;j++)  
  {  
        return(str2[j]);  
  }  
   
 
编译器只要认为有不会执行return(str2[j])语句的情况就会发生并非所有的代码路径都返回值错误,比如说当j<str1.Length+str2.Length不成立的时候,循环内的语句就不会执行。

 

 

2009/7/16

 

The reason is that the method name at the proxy class MUST match the web method name

 

 

<xsd:schema targetNamespace="http://tempuri.org/Imports">

  <xsd:import schemaLocation="http://dadmws-sut01.fareast.corp.microsoft.com:32843/0cb8f522011d4694b93f144da9008e82/SearchAdmin.svc?xsd=xsd0" namespace="http://tempuri.org/" />

  <xsd:import schemaLocation="http://dadmws-sut01.fareast.corp.microsoft.com:32843/0cb8f522011d4694b93f144da9008e82/SearchAdmin.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />

  <xsd:import schemaLocation="http://dadmws-sut01.fareast.corp.microsoft.com:32843/0cb8f522011d4694b93f144da9008e82/SearchAdmin.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

  <xsd:import schemaLocation="http://dadmws-sut01.fareast.corp.microsoft.com:32843/0cb8f522011d4694b93f144da9008e82/SearchAdmin.svc?xsd=xsd3" namespace="http://schemas.datacontract.org/2004/07/Microsoft.Office.Server.Search.Internal.Administration" />

  <xsd:import schemaLocation="http://dadmws-sut01.fareast.corp.microsoft.com:32843/0cb8f522011d4694b93f144da9008e82/SearchAdmin.svc?xsd=xsd4" namespace="http://schemas.datacontract.org/2004/07/Microsoft.Office.Server.Search.Administration" />

  </xsd:schema>

 

 

Wsdl 命令行 要把 这些 都 打上去 wsdl 默认是 soap11

原创粉丝点击