Tag: C#的

这个C ++function的名字是什么?

我正在写一些C ++代码,并错误地省略了函数WSASocket的名称。 但是,我的编译器没有引发错误,并将SOCKET与整数值1相关联,而不是有效的套接字。 有问题的代码应该看起来像这样: this->listener = WSASocket(address->ai_family, address->ai_socktype, address->ai_protocol, NULL, NULL, WSA_FLAG_OVERLAPPED); 但是,看起来像这样: this->listener = (address->ai_family, address->ai_socktype, address->ai_protocol, NULL, NULL, WSA_FLAG_OVERLAPPED); 来自其他语言,这看起来可能是某种匿名types。 这个function的名称是什么,如果它真的是一个function? 它的目的是什么? 当你不知道从哪里开始时,很难find它。

如何比较types

快速的问题:如何比较typestypes(双关语不打算)与另一种types在C#中? 我的意思是,我有一个Type typeField ,我想知道它是否是System.String , System.DateTime等,但typeField.Equals(System.String)不起作用。 任何线索?

json.net有关键的方法?

如果我的回应有关键的“错误”,我需要处理错误,并显示警告框。 json.net中是否存在“haskey”方法? 喜欢: var x= JObject.Parse(string_my); if(x.HasKey["error_msg"]) MessageBox.Show("Error!")

将字典<string,string>转换为分号在c#中的string

简单的开始一天,给一个Dictionary<string, string> ,如下所示: var myDict = new Dictionary<string, string>(); myDict["A"] = "1"; myDict["B"] = "2"; myDict["C"] = "3"; myDict["D"] = "4"; 我希望创build一个string: "A=1;B=2;C=3;D=4" 一个示例实现: var myStringBuilder = new StringBuilder(); bool first = true; foreach (KeyValuePair<string, string> pair in myDict) { if (first) { first = false; } else { myStringBuilder.Append(";"); } myStringBuilder.AppendFormat("{0}={1}", pair.Key, pair.Value); } […]

如何parsing一个月份的名称(string)为一个整数在C#比较?

我需要能够比较一些数组中的月份名称。 如果有一些直接的方式就好了: Month.toInt("January") > Month.toInt("May") 我的谷歌search似乎build议唯一的办法是写自己的方法,但这似乎是一个普遍的问题,我认为它已经在.Net中实现,任何人做过这之前?

在声明中添加自定义消息?

有没有办法添加或编辑由assert引发的消息? 我想用类似的东西 assert(a == b, "A must be equal to B"); 然后,编译器添加行 , 时间等… 可能吗?

哪个更快:if(bool)或if(int)?

哪个值更好用? 布尔真或整数1? 上面的话题让我在if条件下用bool和int做了一些实验。 所以出于好奇,我写了这个程序: int f(int i) { if ( i ) return 99; //if(int) else return -99; } int g(bool b) { if ( b ) return 99; //if(bool) else return -99; } int main(){} g++ intbool.cpp -S为每个函数生成asm代码,如下所示: asm代码f(int) __Z1fi: LFB0: pushl %ebp LCFI0: movl %esp, %ebp LCFI1: cmpl $0, 8(%ebp) je L2 movl […]

是否有可能完全用托pipe的.NET语言编写JIT编译器(本地代码)

我正在写一个JIT编译器的想法,只是想知道是否在理论上可以写在托pipe代码的整个事情。 特别是,一旦你把汇编器生成一个字节数组,你怎么跳到它开始执行?

Azure表存储返回400错误请求

我在debugging模式下运行它,并附上一个图像与exception的细节。 我怎么知道哪里出了问题? 我试图在表格中插入数据。 天青不能给我更多的细节? Obs:存储在Windows Azure上,不在我的机器上。 表已创build,但插入数据时出现此错误 // Retrieve the storage account from the connection string. Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=***;AccountKey=***"); // Create the table client. CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); // Create the table if it doesn't exist. CloudTable table = tableClient.GetTableReference("EmployeeOnlineHistory"); table.CreateIfNotExists(); 这里是插入代码: public static void SetStatus(Employee e, bool value) { try { // Retrieve […]

什么是C#相当于Java的isInstance()?

我知道is和为instanceof ,但reflectionisInstance()方法呢?