c#-3.0

Wrong App.config being loaded

断了今生、忘了曾经 提交于 2019-12-30 09:57:06
问题 I have a .NET 3.5 class library I built that reads an App.config file for values it needs. It can pull the config values just fine when I test it in Visual Studio. To test it, I just change the project to a console application and execute a method call. I have the need to call this class library from many other .NET programs, and I want the class library to be self sufficient (I should be able to call it from any other program, and it should use its own config file, not know about any calling

Drag and Drop between 2 list boxes

萝らか妹 提交于 2019-12-30 07:22:11
问题 Trying to implement drag and drop between 2 listboxes and all examples I've seen so far don't really smell good. Can someone point me to or show me a good implementation? 回答1: Here's a sample form. Get started with a new WF project and drop two list boxes on the form. Make the code look like this: public partial class Form1 : Form { public Form1() { InitializeComponent(); listBox1.Items.AddRange(new object[] { "one", "two", "three" }); listBox1.MouseDown += new MouseEventHandler(listBox1

C# 3.0 :Automatic Properties - what would be the name of private variable created by compiler

妖精的绣舞 提交于 2019-12-30 06:24:15
问题 I was checking the new features of .NET 3.5 and found that in C# 3.0, we can use public class Person { public string FirstName { get; set; } public string LastName { get; set; } } instead of private string name; public string Name { get { return name; } set { name = value; } } If i use the Automatic Properties,what will be the private variable name for Name ? the tutorials on internet says that compiler will automatically create a private variable.So how can i use /access the private variable

Is there any native way in ASP.NET to do a “success message”?

僤鯓⒐⒋嵵緔 提交于 2019-12-30 06:17:03
问题 Say you have something like an ASP.NET ASP:DetailsView to show and edit a single record in a database. It's simple to record the error cases... you add validation and a validation summary. When your update form fails validation it naturally makes noise: it shows the validation message and/or the validation summary. Not a single code behind is required. But then, you pass validation, and it makes your update completely silently. There's no sense that anything happened, and there doesn't seem

Is there any native way in ASP.NET to do a “success message”?

烈酒焚心 提交于 2019-12-30 06:16:06
问题 Say you have something like an ASP.NET ASP:DetailsView to show and edit a single record in a database. It's simple to record the error cases... you add validation and a validation summary. When your update form fails validation it naturally makes noise: it shows the validation message and/or the validation summary. Not a single code behind is required. But then, you pass validation, and it makes your update completely silently. There's no sense that anything happened, and there doesn't seem

ASP.NET GridView Newbie Questions About TFOOT and TH

ⅰ亾dé卋堺 提交于 2019-12-30 05:23:56
问题 Greetings! I'm still learning about the GridView control and I have one bound to an ObjectDataSource. My Web form looks like this: <asp:GridView ID="ourGrid" runat="server" DataSourceID="ourDataSource" onrowdatabound="ourGrid_RowDataBound" HeaderStyle-CssClass="header_style" AlternatingRowStyle-CssClass="altrow_style" ShowFooter="true"> <columns> <asp:BoundField DataField="Name" HeaderText="Full Name" /> <asp:BoundField DataField="Gender" HeaderText="Gender" /> <asp:BoundField DataField=

Gray out the Desktop screen except a selected control in c#

南楼画角 提交于 2019-12-29 08:08:08
问题 I want to select a UI control to be clicked and gray out the rest of the desktop screen semi-transparently. I was thinking bitmap painting the whole screen but it is very slow process. I guess someone out there know in WPF how to do that. I don't have experiance in WPF. I wanted to do this on Windows 7. 回答1: Basically you want to show a top-level full screen transparent window which is not focusable and doesn't respond to input. You can then use this window to draw the overlay manually. I

If an extension method has the same signature as a method in the sealed class, what is the call precedence?

旧时模样 提交于 2019-12-29 06:41:08
问题 I was reading about extension methods in C# 3.0. The text I'm reading implies that an extension method with the same signature as a method in the class being extended would be second in order of execution - that is, the method in the sealed class gets called. If this is the case, how can you extend the sealed class ? 回答1: Indeed, the actual method takes precedence over the extension method. And just to make it clear - "order of execution" suggests both might be called; only the original

Good Case For Interfaces

不羁的心 提交于 2019-12-29 03:39:09
问题 I work at a company where some require justification for the use of an Interface in our code (Visual Studio C# 3.5). I would like to ask for an Iron Clad reasoning that interfaces are required for. (My goal is to PROVE that interfaces are a normal part of programming.) I don't need convincing, I just need a good argument to use in the convincing of others. The kind of argument I am looking for is fact based, not comparison based (ie "because the .NET library uses them" is comparison based.)

Possible to get type of an aliased type in c#?

和自甴很熟 提交于 2019-12-28 06:46:38
问题 Type.GetType("System.String") Is there a lookup for the aliases available somewhere? Type.GetType("string") returns null . 回答1: This is not possible programmatically, since the 'aliases' are in fact keywords introduced in C#, and Type.GetType (like every other framework method) is part of the language-independent framework. You could create a dictionary with the following values: bool System.Boolean byte System.Byte sbyte System.SByte char System.Char decimal System.Decimal double System