草庐IT

内部的

全部标签

c# - System.String 的内部结构

我用反射查看了System.String的内部字段,发现了三个字段:m_arrayLengthm_stringLengthm_firstChar我不明白这是怎么回事。m_arrayLength是一些数组的长度。这个数组在哪里?它显然不是字符串类的成员字段。m_stringLength是有道理的。它是字符串的长度。m_firstChar是字符串中的第一个字符。所以我的问题是字符串的其余字符在哪里?如果不在字符串类中,字符串的内容存储在哪里? 最佳答案 第一个字符提供对缓冲区中第一个字符的内存地址的访问(通过&m_firstChar)。

c# - C# 中的内部属性 setter

我正在尝试找出解决此问题的好方法。我有一个实现ICustomer接口(interface)的Customer类。这个接口(interface)有很多属性:publicinterfaceICustomer{stringFirstName{get;set;}stringLastName{get;set;}}不过,我只希望某些类能够设置这些属性;即,项目中的那些类。所以我考虑将setter设置为internal:publicclassCustomer:ICustomer{stringFirstName{get;internalset;}stringLastName{get;internals

c# - ASP.NET + C# HttpContext.Current.Session 为空(WebService 内部)

这是我发起session的方式protectedvoidSession_Start(objectsender,EventArgse){HttpContext.Current.Session["CustomSessionId"]=Guid.NewGuid();}在我的类库下的解决方案中,我正在尝试访问它并获得空异常:stringsess=HttpContext.Current.Session["CustomSessionId"];这是我在web.config和app.config中的配置(在我的库中)(应用程序配置) 最佳答案 根据您

c# - C# 中的绝对/外部和内部 namespace 混淆

usingFoo.Uber;namespaceMyStuff.Foo{classSomeClass{voidDoStuff(){//Iwanttoreferencetheouter"absolute"Foo.Uber//butthecompilerthinksI'mreferingtoMyStuff.Foo.Ubervarx=Foo.Uber.Bar();}}}我该如何解决这个问题?只是将using语句移动到我的命名空间中并没有帮助。 最佳答案 您可以使用namespacealiasqualifier来做到这一点(通常为global

c# - 当从另一个项目内部提供 api 时,如何在 Swashbuckle/Swaggerwork 中创建 url 路径?

全部。我正在尝试使用Swashbuckle包记录WebApi2。如果API自行运行,一切都很好,即localhost/api/swagger将我带到ui,将localhost/api/swagger/docs/v1带到json。然而,生产应用程序通过从另一个-现在是Web项目(主要应用程序)中的global.asax.cs运行该项目的webapiconfig方法来初始化同一个Webapi项目。所以apiurl看起来像localhost/web/api而不是localhost/api。现在swashbuckle根本不是那样工作的。localhost/api/swagger生成错误无法加载

c# - gacutil 不被识别为内部或外部命令?

我已经通过添加外部DLL引用创建了一个控制台应用程序。现在我必须将我的外部Dll部署到我的程序集。当我试图在GAC中添加我的dll时。GACUTIL.EXE/iMyLibrary.dll将我的dll添加到程序集中的命令,显示错误*gacutilisnotrecognizedasaninternalorexternalcomma*我该如何解决? 最佳答案 对于Windows10路径是:C:\ProgramFiles(x86)\MicrosoftSDKs\Windows\v7.0A\Bin

c# - protected 内部

这个问题在这里已经有了答案:HowtomakeapropertyprotectedANDinternalinC#?(8个答案)关闭9年前。MSDN上的C#语言引用将“protected内部”定义为“访问仅限于当前程序集或从包含类派生的类型”。但从语义的角度来看,“protected内部”对我来说听起来像是“既protected又内部”,这意味着该成员只能由同一程序集中的那些派生类访问。是否有具有相同含义的访问修饰符?

c# - 测试函数内部或外部是否需要更好?

什么是最佳实践?调用一个函数然后返回,如果你测试了一些东西,或者测试了一些东西然后调用?我更喜欢函数内部的测试,因为它可以更轻松地查看调用了哪些函数。例如:protectedvoidApplication_BeginRequest(objectsender,EventArgse){this.FixURLCosmetics();}和privatevoidFixURLCosmetics(){HttpContextcontext=HttpContext.Current;if(!context.Request.HttpMethod.ToString().Equals("GET",StringC

c# - 使用 XML 类属性,如何用内部文本和属性表示 XML 标记?

假设我有这个XML文件:24.0Sunny我正在尝试创建一个C#类来使用属性来表示它,以便调用XmlSerializer并具有强类型标记访问权限。我认为结构看起来像这样:[XmlRoot("weather")]publicclassWeatherData{[XmlElement("temp")]publicstringTemp{get;set;}[XmlElement("current-condition")]publicCurrentConditioncurrentCond=newCurrentCondition();}publicclassCurrentCondition{[Xml

c# - 混淆 : Internal, 保护和保护内部

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Whatisthedifferencebetween'protected'and'protectedinternal'?WhatisthedifferencebetweenPublic,Private,Protected,andNothing?代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespacetestanotherlib{publicclassA{internalvoidInt