.net-3.5

Convert delegate to Action<T> (Action<T1,T2>)

穿精又带淫゛_ 提交于 2019-12-25 03:00:11
问题 I have a DB class that makes all DB calls like below: public delegate void Part1_Callback(string message); public delegate void Part2_Callback(DataTable dt); public delegate void Part3_Callback(DataTable dt, int x, int y); public delegate void ErrorHandler(string message); public class CommandAndCallback<TCallback> { public SqlCommand Sql { get; set; } public TCallback Callback { get; set; } public ErrorHandler Error { get; set; } } class DB : SingletonBase<DB> { public static readonly string

Where to store common application settings

别说谁变了你拦得住时间么 提交于 2019-12-25 02:44:58
问题 I want to move my application settings out of XAML and into a config file. For example, ToolTips and Content strings for Buttons/CheckBoxes and Labels. Is this the job of a ResourceDictionary, or should I use the App.Config or Settings.settings file? The ToolTips and Content strings are not really per user, they are more Application wide and may change if the UI is internationalized. EDIT: I hear use a Resource Dictionary or use a App.Config , what is the difference? Thanks! 回答1: Tool tips

How to use IList.Contains() method to find an object

淺唱寂寞╮ 提交于 2019-12-25 02:34:10
问题 I have a list of Persons inside a Company Class. public class Company{ IList<Person> persons; } Then I have a List of companies, IList<Company> companies; Now I have a name (say "Lasantha"). If this name is a part of the name of any person in a company, I want to find that company. I tried using companies.Contains() method. I overrided the object.Equals method, inside the Person class as this, public override bool Equals(object o) { var other = o as Person; return this.Name.ToLower().Contains

HttpWebRequest timeout in 3.5sp1

﹥>﹥吖頭↗ 提交于 2019-12-25 02:27:11
问题 We have a service that opens several HttpWebRequests. It ran fine under 3.0 until we upgraded the server to .net 3.5sp1. Now we get timeouts while waiting for the request. (we have verified that the endpoint is up and running). There are a few things that make this interesting. Increasing the number of max connections will let it run for a little longer before the timeouts occur. Also, once we see the requests waiting, if we open Fiddler they all succeed. These requests open via a Timer

Is List<Object> a good replacement for ArrayList?

筅森魡賤 提交于 2019-12-25 02:22:15
问题 ArrayList , which I use in legacy Compact Framework code, does not seem to be available in newfangled (.NET 4.5.1) code. I am storing instances of custom classes in it. What is a good replacement for it - List<Object> , or is there something more suitable? 回答1: As @HighCore mentioned in his comment, you should use the generic form of List, List<T> . If you have several classes defined that you need to include in that List, they probably have common properties, methods. In that case, you can

Need help creating Linq.Expression to Enumerable.GroupBy

孤街浪徒 提交于 2019-12-25 01:46:39
问题 I am attempting to generate an Expression tree that ultimately calls a series of GroupBy methods on the Enumerable type. In simplified form I am attempting something like this: IEnumerable<Data> list = new List<Data>{new Data{Name = "A", Age=10}, new Data{Name = "A", Age=12}, new Data{Name = "B", Age=20}, new Data{Name="C", Age=15}}; Expression data = Expression.Parameter(typeof(IEnumerable<Data>), "data"); Expression arg = Expression.Parameter(typeof(Data), "arg"); Expression nameProperty =

how to add .net 3.5 to visual studio 2010?

时光怂恿深爱的人放手 提交于 2019-12-25 00:36:07
问题 I tried to installed visual studio 2010 and it installed .net 4 only. i want to add .net 3.5 to the visual studio. I have installed the 3.5 and now i'm having problem with add .net 3.5 to the new visual studio. how can i add 3.5 to vs 2010? 回答1: You don't need to "add" .NET 3.5 to VS2010. When you create a new project, you just specify which version of .NET you want to target. (You can change this later, too, in project properties.) 回答2: Try this link: http://www.microsoft.com/downloads/en

Modifying just the path part of a Hyperlink's NavigateUrl in C#

…衆ロ難τιáo~ 提交于 2019-12-24 21:10:03
问题 I would like to modify the NavigateUrl property of a Hyperlink control. I need to preserve the querystring but change the path of the hyperlink's URL. Something along these lines: var control = (Hyperlink) somecontrol; // e.g., control.NavigateUrl == "http://www.example.com/path/to/file?query=xyz" var uri = new Uri(control.NavigateUrl); uri.AbsolutePath = "/new/absolute/path"; control.NavigateUrl = uri.ToString(); // control.NavigateUrl == "http://www.example.com/new/absolute/path?query=xyz"

Programicatlly visit (all) ASP.Net page(s) in a website?

↘锁芯ラ 提交于 2019-12-24 20:51:26
问题 In the Security model for out ASP.Net website (.Net 3.5) we store the page name: page.GetType().Name as the primary key in a database table to be able to lookup if a user has access to a certain page. The first time a page is visited this record is created automatically in the database. We have exported these database statements to insert scripts, but each time a new page gets created we have to update the scripts, not a huge issue, but I would like to find an automated way to do this. I

How to insert specific excel row into datagridview using excel rowindex

佐手、 提交于 2019-12-24 19:17:14
问题 I am performing search within excel workbook using small c# application using below method public void SearchExcelFiles(string FilePath) { string ConnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FilePath + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\";"; Microsoft.Office.Interop.Excel.Application oXL = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook oWB; Microsoft.Office.Interop.Excel.Range currentFind = null; Microsoft.Office.Interop