.net-4.0

Foreach on enum types in template

和自甴很熟 提交于 2021-02-11 13:03:53
问题 enum MyEnum { type1, type2, type3 } public void MyMethod<T>() { ... } How to make forach on enum to fire MyMethod<T> on every enum? I try something with foreach (MyEnum type in Enum.GetValues(typeof(MyEnum))) {...} But still don't know how to use this type inside foreach with MyMethod<T> as T 回答1: Is this what you are trying to do? class Program { static void Main(string[] args) { EnumForEach<MyEnum>(MyMethod); } public static void EnumForEach<T>(Action<T> action) { if(!typeof(T).IsEnum)

How to organize a HIERARCHY of non-UI threads and get status and progress back for UI consumption

廉价感情. 提交于 2021-02-10 07:26:20
问题 Figure 1 - Working Demo I'm running a winforms application and I have implemented a status / progress TreeView. It can display the status (by icon) and progress of a (possibly hierarchical) set of tasks to accomplish. My question is not about how to implement the TreeView control itself. I've got that part covered. The TreeView is merely the way the background work is going to status / progress itself to the user. I have a set of methods that I want to run on not the main UI thread. They need

How to Force my C# windows forms to use arabic number?

和自甴很熟 提交于 2021-02-10 06:31:41
问题 I am trying to force my forms to use arabic format like displaying (1-2-3-4-..,etc) numbers as (٠‎ , ١‎ , ٢‎ , ٣‎ , ٤‎ , ٥‎ , ٦‎ , ٧‎ , ٨‎ , ٩‎) in all areound my forms no matter if it is Textbox ,or lables or whatever it is I searched and found a lout of question talking about this issue most of them not working and the other I believe are not seems to be good answer like the accepted answer here and as shown below what I have tried on form loading which has no effect on my issue and here is

How to Force my C# windows forms to use arabic number?

六月ゝ 毕业季﹏ 提交于 2021-02-10 06:31:13
问题 I am trying to force my forms to use arabic format like displaying (1-2-3-4-..,etc) numbers as (٠‎ , ١‎ , ٢‎ , ٣‎ , ٤‎ , ٥‎ , ٦‎ , ٧‎ , ٨‎ , ٩‎) in all areound my forms no matter if it is Textbox ,or lables or whatever it is I searched and found a lout of question talking about this issue most of them not working and the other I believe are not seems to be good answer like the accepted answer here and as shown below what I have tried on form loading which has no effect on my issue and here is

Changing Printer Trays During Print Job

空扰寡人 提交于 2021-02-08 08:12:22
问题 Is there a way to switch printer trays during a print job? I've been asked to put together a pick/pack slip program. They want the inventory pick slip to be printed on a sheet of colored paper, the pack slips to be on white paper, and they want it properly collated (pick, pack, pack, pack, pack; pick, pack, pack, pack, pack; ...). I found some other threads on setting default trays, but didn't find anything on alternating trays during the job. Maybe I'm not searching on the right thing. Don't

obtaining the Windows Time Zone index when using TimeZoneInfo.GetSystemTimeZones();

自古美人都是妖i 提交于 2021-02-07 19:15:21
问题 so something I've been struggling with is pulling a list of time zones in .net 4 (C#) to populate a drop down list on a form. I know I can do this: var TimeZoneList = TimeZoneInfo.GetSystemTimeZones(); which will retrieve a list of time zones in a TimeZoneInfo class which has an 'Id' property. The ID is not the Microsoft time zone index though. For example, with eastern time, the 'Id' is simply 'Eastern Standard Time' where as the internal index is '35'. (The rest of the indices are here:

obtaining the Windows Time Zone index when using TimeZoneInfo.GetSystemTimeZones();

老子叫甜甜 提交于 2021-02-07 19:13:46
问题 so something I've been struggling with is pulling a list of time zones in .net 4 (C#) to populate a drop down list on a form. I know I can do this: var TimeZoneList = TimeZoneInfo.GetSystemTimeZones(); which will retrieve a list of time zones in a TimeZoneInfo class which has an 'Id' property. The ID is not the Microsoft time zone index though. For example, with eastern time, the 'Id' is simply 'Eastern Standard Time' where as the internal index is '35'. (The rest of the indices are here:

Is using Lazy<T> bad for performance?

为君一笑 提交于 2021-02-07 05:28:25
问题 Recently I was having some issues with a singelton class that was lazy initializing a dictionary where a second thread would try to use it before it had actually been populated. So I implemented the variable initialization through the Lazy<T> class. Here is my code: private static Dictionary<string, string> GroupDefaults { get { return mGroupDefaults.Value; } } private static Lazy<Dictionary<string, string>> mGroupDefaults = new Lazy<Dictionary<string,string>>(delegate { Dictionary<string,

Search for a value in List<Dictionary<string, object>>

时间秒杀一切 提交于 2021-02-07 03:54:07
问题 I have a List< Dictionary < string, object >> variable as follows. private static List<Dictionary<string, object>> testData = new List<Dictionary<string, object>>(100); // Just Sample data for understanding. for (int i = 0; i < 100; i++) { var test = new Dictionary<string, object> { { "aaa", "aaa" + i % 4 }, { "bbb", "bbb" + i % 4 }, { "ccc", "ccc" + i % 4 }, { "ddd", "ddd" + i % 4 }, { "eee", "eee" + i % 4 }, { "fff", "fff" + i % 4 }, { "ggg", "ggg" + i % 4 }, { "hhh", "hhh" + i % 4 }, {

Search for a value in List<Dictionary<string, object>>

岁酱吖の 提交于 2021-02-07 03:53:22
问题 I have a List< Dictionary < string, object >> variable as follows. private static List<Dictionary<string, object>> testData = new List<Dictionary<string, object>>(100); // Just Sample data for understanding. for (int i = 0; i < 100; i++) { var test = new Dictionary<string, object> { { "aaa", "aaa" + i % 4 }, { "bbb", "bbb" + i % 4 }, { "ccc", "ccc" + i % 4 }, { "ddd", "ddd" + i % 4 }, { "eee", "eee" + i % 4 }, { "fff", "fff" + i % 4 }, { "ggg", "ggg" + i % 4 }, { "hhh", "hhh" + i % 4 }, {