Tag: c#

C#如何使用选取框进度条加载表单?

我创建了一个只有带字幕样式的进度条的loadingForm。 在我的mainForm中我试图这样做: //before downloading loadingForm lf = new loadingForm(); lf.Show(); //start downloading //finishdownloading lf.Close(); 显示了loadingForm但没有出现进度条,表格看起来像是崩溃了。 完成下载后,loadingForm关闭,我的应用程序继续正常运行。 在loadingForm我只有: void loadingForm_Load(object sender, EventArgs e) { progressbar1.visible = true; } 我已经将progressbar1样式设置为loadingForm.design中的选取框。 我该如何解决? 感谢您的帮助。

在wpf中找不到“Resources”文件

我是WPF的新手。 我需要在资源文件resx上添加引用并从中获取字符串。 …. 我收到一个错误:名称“Resources”在命名空间“clr-namespace:SelectObjectsWindow.Properties”中不存在。 我正在搜索有关此信息,并找到几个建议:设置resx文件的“公共”访问修饰符。 在“嵌入式​​资源”上更改resx的Build Action属性。 所以,我做到了,但没有改变。 我检查了所有命名空间。 似乎没问题。 我不知道,还有什么我应该尝试的。 在.cs中我可以毫无错误地执行此操作 var res = Properties.Resources.Res1; 有人知道,有什么不对吗?

定义动态数组

如何在C#中定义动态数组?

服务器标签格式不正确

我在GridView上有以下图像按钮,我想通过传递参数调用OnClientClick来调用javascript方法。 我收到Server Tag没有很好的错误。 我尝试将双引号更改为单引号等,仍然是同一个问题。 OnClientClick=”return ConfirmOnDelete(”);” <asp:ImageButton ID="imgDelete" CommandName="Delete" ImageUrl="~/images/fbclose.png" AlternateText="Delete" runat="server" OnClientClick="return ConfirmOnDelete('’);”/>

“使用”是否具有任何优势?

引用某些方法时,可以使用using或显式键入整个命名空间。 使用一种方法比另一种方法有任何速度优势,还是只是简单地输入整个命名空间? 谢谢

对“C:\ Windows \ system32 \ config \ systemprofile”路径的访问被拒绝

我正在使用Google Calendar Api和我的一个项目。 我不知道如何,但下面显示的错误是令人不安的。 AppFlowMetadata代码。 public class AppFlowMetadata : FlowMetadata { private static readonly IAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer { ClientSecrets = new ClientSecrets { ClientId = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com”, ClientSecret = “xxxxx_xxxxxxxxxxxxxxxxx” }, Scopes = new[] { CalendarService.Scope.Calendar }, DataStore = new FileDataStore(“Calendar.Api.Auth.Store”) }); public override string GetUserId(Controller controller) { var user = controller.Session[“UserID”]; if […]

以与创建相反的顺序处理对象?

我在我编写的代码中面临一个反复出现的问题:修改一些全局值(我将使用注册表值作为示例),然后尝试将修改恢复为原始状态。 我以为我会尝试使用IDisposable来解决这个问题。 创建时,对象将读取注册表值,将其存储在本地,然后进行修改。 当被破坏时,它将恢复设置。 它将使用这样的东西: using(RegistryModification mod = new RegistryModification(“HKCR\SomeValue”, 42)) { // reg value now modified to 42, do stuff } // Object gets disposed, which contains code to revert back the setting 如果只进行一次修改,应该工作得很好。 但是如果进行了多次修改,或者调用者没有使用’using’结构创建对象,我会发现出现问题。 public void Foo() { // assume HKCR\SomeValue starts as ’13’ // First object reads HKCR\SomeValue and stores ’13’, then […]

如何同时为C#类分配多个名称

有没有一种方法可以为C#类赋予多个名称,例如: Foo {} class AlternativeFooName是指Foo 我希望能够通过两个名称,Foo和AlternativeFooName访问Foo,但不必从Fooinheritance。 对此应用程序将为类提供一个长描述性名称,但在使用时可以缩写它,例如: 而不是Foo f = new Foo(); 能够使用具有相同效果的以下内容:F f = new F();

从多个林环境中获取Domain Local Group的所有成员

我有一个域本地组,它是林A中域A的一部分。 我试图迭代这个组中的所有成员。 它迭代遍历林A的所有域,但不会迭代域B中的任何组成员,在林B中。 是从不同的森林开始迭代相同代码的唯一方法吗? 我们已尝试使用System.DirectoryServices.AccountManagement类,但它们和Windows Server 2012域控制器似乎存在问题。 private List getUsersInGroup(string groupDN) { var users = new List(); using (DirectoryEntry de = new DirectoryEntry(“GC://rootDSE”)) { var rootName = de.Properties[“rootDomainNamingContext”].Value.ToString(); using (var userBinding = new DirectoryEntry(“GC://” + rootName)) { using (DirectorySearcher adSearch = new DirectorySearcher(userBinding)) { adSearch.ReferralChasing = ReferralChasingOption.All; adSearch.Filter = String.Format(“(&(memberOf={0})(objectClass=person))”, groupDN); adSearch.PropertiesToLoad.Add(“distinguishedName”); adSearch.PropertiesToLoad.Add(“givenname”); adSearch.PropertiesToLoad.Add(“samaccountname”); adSearch.PropertiesToLoad.Add(“sn”); […]

为什么在定义接口的方法和属性前面没有修饰符(public,private,protected)?

可能重复: 您是否有理由无法在方法或界面中定义访问修饰符? 你好, 我对接口感到好奇。 假设我有以下界面的定义 public interface IPersone { string FirstName { get; set; } string LastName { get; set; } int CalculateAge(int YearOfBirth); } 为什么在定义接口的方法和属性前面没有修饰符(public,private,protected)? 有什么理由吗? 谢谢你的帮助