草庐IT

TYPE_BOOL

全部标签

c# - AutoResetEvent 与 bool 值停止线程

我在工作线程中有一个对象,我可以指示它停止运行。我可以使用bool或AutoResetEvent来实现:bool值:privatevolatilebool_isRunning;publicvoidRun(){while(_isRunning){doWork();Thread.Sleep(1000);}}自动重置事件:privateAutoResetEvent_stop;publicvoidRun(){do{doWork();}while(!_stop.WaitOne(1000));}然后Stop()方法会将_isRunning设置为false,或调用_stop.Set()。除了Auto

C# : Implicit conversion between '<null>' and 'bool'

当我尝试转换object时收到奇怪的错误消息至bool,这是我的代码:publicpartialclassModifierAuteur:DevExpress.XtraEditors.XtraForm{publicModifierAuteur(objectgetKeyDecesCheckBox){decesCheckBox.Checked=getKeyDecesCheckBox==null?null:(bool)getKeyDecesCheckBox;}}这是错误信息:Typeofconditionalexpressioncannotbedeterminedbecausethereisn

c# - 将 "C# friendly type"名称转换为实际类型 : "int" => typeof(int)

我想得到一个System.Type给定一个string指定一个(原始)类型的C#友好名称,基本上是C#编译器在阅读C#源代码时的方式。我觉得描述我所追求的东西的最佳方式是以单元测试的形式。我希望存在一种通用技术可以使以下所有断言都通过,而不是尝试对特殊C#名称的特殊情况进行硬编码。TypeGetFriendlyType(stringtypeName){...??...}voidTest(){//usingfluentassertionsGetFriendlyType("bool").Should().Be(typeof(bool));GetFriendlyType("int").Sho

c# - 无法设置 Content-Type header

我在设置HttpClient的Content-Type时遇到问题。我跟着这个问题:HowdoyousettheContent-TypeheaderforanHttpClientrequest?但仍然没有运气。StringrcString=JsonConvert.SerializeObject(newRoadsmartChecks(){userguid=user_guid,coords=coordinates,radius=(radius*100)+""},ROADSMART_JSON_FORMAT,JSONNET_SETTINGS);HttpClientc=newHttpClient(

c# - 将 sbyte[] 转换为 bool[] 并将 char[] 转换为 short[]

有没有显式转换/强制转换sbyte[]或byte[]到bool[]char[]到short[]/ushort[]在CIL中,您经常会看到诸如stelemTypesbyte(ldlocpArray)ldc_i41ldc_i40正在执行pArray[1]=true,其中pArray是bool[]类型的一维数组。我想通过做在c#中复制它(sbyte[])pArray[1]=1;不幸的是,C#编译器不允许这样做。 最佳答案 未记录的技巧,风险自负:(例如here以及许多其他地方)[StructLayout(LayoutKind.Explic

c# - 安全异常 : Request for the permission of type 'System.Net.Mail.SmtpPermission'

这是“在本地工作,在服务器上不工作”的帖子之一。我有一个发送电子邮件的简单联系表单。在服务器上,我得到以下异常:SecurityExceptionDescription:Theapplicationattemptedtoperformanoperationnotallowedbythesecuritypolicy.Tograntthisapplicationtherequiredpermissionpleasecontactyoursystemadministratororchangetheapplication'strustlevelintheconfigurationfile.Ex

c# - Expression<Func<T,bool>> 声明是什么意思?

有人可以用表达表达式的含义以及如何调用它的方式来解释以下声明吗?voidDelete(Expression>expression)whereT:class,new();我是这样读的:删除T类型的对象,通过传入一个参数为T类型对象的lambda表达式返回bool.还有,你能不能换Funcexpression和Predicateexpression 最佳答案 此方法可能是集合类型的成员,是吗?“谓词”是对“这个东西是那个集合的成员吗?”这个问题说"is"或“否”的任何设备。因此,集合“整数偶数正整数”的谓词将是x=>x>0&&x%2==

c# - 如何调整 "is a type but is used like a variable"?

我正在尝试在网络服务中生成一些代码。但它返回了2个错误:1)List是一种类型,但像变量一样使用2)方法“Customer”没有重载接受“3个参数”[WebService(Namespace="http://tempuri.org/")][WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)][ToolboxItem(false)]publicclasswstest:System.Web.Services.WebService{[WebMethod]publicListGetList(){Listli=List();li.A

c# - 将 Eval ("bitValue") 转换为 Bool

我在ItemTemplate中有一个带有超链接控件的ListView。如果返回值为0(假),我想显示链接,如果返回值为1(真),则不显示链接。到目前为止我有这个:'Text="ReviewEnquiry"Visible=''/>...但这会导致“指定的转换无效”异常。我在其他地方看到的示例表明这应该有效。我可以确认Locked列只返回0或1(来自SQLServer)——当然这些应该很容易从bit/int转换为bool?? 最佳答案 如果Locked是一个int你应该这样做:但是这也应该有效,所以当Locked>0时它返回true无论

C#:创建具有 bool 返回类型的多播委托(delegate)

海技术人员,在C#中,我们如何定义接受DateTime对象并返回bool值的多播委托(delegate)。谢谢 最佳答案 publicdelegateboolFoo(DateTimetimestamp);这是使用您描述的签名声明委托(delegate)的方法。所有委托(delegate)都可能是多播的,它们只需要初始化。如:publicboolIsGreaterThanNow(DateTimetimestamp){returnDateTime.Nowtimestamp;}Foof1=IsGreaterThanNow;Foof2=Is