草庐IT

base_type

全部标签

c# - 如何使用局部变量作为类型?编译器说 "it is a variable but is used like a type"

在运行时,我不知道什么类型的变量v1是。为此,我写了很多ifelse声明:if(v1isShellProperty){v2=(v1asShellProperty).Value;}elseif(v1isShellProperty){v2=(v1asShellProperty).Value;}elseif(v1isShellProperty){v2=(v1asShellProperty).Value;}elseif(v1isShellProperty){v2=(v1asShellProperty).Value;}唯一的区别在于ShellProperty.所以不要用很多ifelse来写这篇文

c# - 使用 RegEx 验证字符串是否为 base64 格式?

我一直在寻找如何验证base64字符串并遇到了这个问题。^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$我需要一些帮助来让它允许“==”和“=”。谢谢 最佳答案 这应该表现得非常好。privatestaticreadonlyHashSet_base64Characters=newHashSet(){'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T'

c# - PropertyInfo 实例上的 SetValue 错误 "Object does not match target type"c#

在以前的项目中的不同地方使用了带有这段代码的Copy方法(处理具有相同命名属性但不派生自公共(public)基类或实现公共(public)接口(interface)的对象)。新的工作地点,新的代码库-现在即使在非常简单的示例中,它也会在SetValue处失败并显示“对象与目标类型不匹配”......并且它在上周工作......publicstaticvoidCopy(objectfromObj,objecttoObj){TypefromObjectType=fromObj.GetType();TypetoObjectType=toObj.GetType();foreach(System

c# - LINQ to Entities Group By 表达式给出 'Anonymous type projection initializer should be simple name or member access expression'

我在这个表达式中遇到了上述错误:varaggregate=fromtinentities.TraceLinesjoinminentities.MethodNames.Where("it.NameLIKE@searchTerm",newObjectParameter("searchTerm",searchTerm))ont.MethodHashequalsm.MethodHashwhere(t.CallTypeId&(int)types)==t.CallTypeId&&t.UserSessionProcessId==m_SessionIdgrouptbym.Nameintodselect

c# - 检查 System.Type 是否是给定类的后代的最佳方法

考虑以下代码:publicclassA{}publicclassB:A{}publicclassC:B{}classD{publicstaticboolIsDescendantOf(thisSystem.TypethisType,System.TypethatType){///???}voidMain(){AcValue=newC();C.GetType().IsDescendantOf(cValue.GetType());}}实现IsDescendantOf的最佳方法是什么? 最佳答案 Type.IsSubclassOf()判断当

c# - 这个和base的区别

我很想知道C#中this和base对象之间的区别。使用它们时的最佳做法是什么? 最佳答案 thisbase表示当前类实例parent。使用示例:publicclassParent{publicvirtualvoidFoo(){}}publicclassChild:Parent{//callconstructorinthecurrenttypepublicChild():this("abc"){}publicChild(stringid){}publicoverridevoidFoo(){//callparentmethodbase.

c# - T4代码生成: access types in current project

使用T4代码生成,是否可以访问当前项目中定义的类型?例如,如果我有一个接口(interface)并且我想将它的实现委托(delegate)给另一个类,即interfaceIDoSomething{publicvoiddo_something();}classDoSomethingImpl:IDoSomething{publicvoiddo_something(){//implementation...}}classSomeClass:IDoSomething{IDoSomethingm_doSomething=newDoSomethingImpl();//forwardcallstoi

c# - 使用Base64编码的公钥验证RSA签名

简而言之,这是我的问题:privatestringpublicKeyString="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVGUzbydMZS+fnkGTsUkDKEyFOGwghR234d5GjPnMIC0RFtXtw2tdcNM8I9Qk+h6fnPHiA7r27iHBfdxTP3oegQJWpbY2RMwSmOs02eQqpKx4QtIjWqkKk2Gmck5cll9GCoI8AUAA5e0D02T0ZgINDmo5yGPhGAAmqYrm8YiupwQIDAQAB";/*Sometransformationrequired,usingpu

c# - 在 C# 中实现安全的鸭子类型(duck typing)

看了之后如何Go处理接口(interface)并喜欢它,我开始考虑如何在C#中实现类似的duck-typing,如下所示:varmallard=newMallard();//doesn'timplementIDuckbuthastherightmethodsIDuckduck=DuckTyper.Adapt(mallard);DuckTyper.Adapt方法将使用System.Reflection.Emit动态构建适配器。也许有人已经写过这样的东西。我想这与模拟框架已经做的并没有太大不同。但是,如果Mallard实际上没有正确的IDuck方法,这将在运行时抛出异常。为了在编译时尽早发

c# - 嵌入式 RavenDB 出现 "Could not find transactional storage type"错误

我能够根据在以下位置找到的代码成功运行RavenDB的简单测试:http://ravendb.net/tutorials/hello-world接下来我尝试以嵌入式方式运行它,但我不断收到以下错误:Message:Couldnotfindtransactionalstoragetype:Raven.Storage.Esent.TransactionalStorage,Raven.Storage.EsentStackTrace:atRaven.Database.Config.InMemoryRavenConfiguration.CreateTransactionalStorage(Act