.net-2.0

Use string.Replace to match whole words

杀马特。学长 韩版系。学妹 提交于 2019-12-20 03:16:58
问题 I'm using NET 2.0 and WinForms. Currently, I need a code to replace a string with another one in a given text, but in the text it should only look for whole words. What I mean is: string name = @"COUNTER = $40 CLOCK_COUNTER = $60"; name = name.Replace("COUNTER", "COUNT"); It should only replace the first instance of COUNTER with COUNT , because that's whole word. However, it seems string.Replace does not take whole word into consideration. Please don't recommend regex. I have already tried it

How can I update Crate IDs of List of Fruits in single SQL query in c#

谁说胖子不能爱 提交于 2019-12-20 03:11:47
问题 In reference to my question, how can i update SQL table logic I want a query which will do something like this, I my last question was confusing hence I am asking a different question. How can I update Crate IDs of List of Fruits in single SQL query in c# FruitID and CrateID are foriegn keys and will always in other tables. 回答1: Try using IN : UPDATE FRUITS SET CRATE = 'CRATE 7' WHERE FRUITID IN (1, 2, 3) Or UPDATE FRUITS SET CRATE = 'CRATE 7' WHERE FRUITName IN ('Mango1', 'Mango2', 'Apple 6'

.Net 'Any Framework' configuration

扶醉桌前 提交于 2019-12-20 01:36:18
问题 I built a program in C# .NET 2.0 that works great also under framework 3.0 and 3.5. But if .NET Framework 4.0 is the only framework installed, it does not working, it requires the user to install 2.0. i found the following configuration in google: <startup> <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/> </startup> After adding this to the app.config, my program works on .NET Framework 4.0 without any problems! What i searching for is a .NET 'Any Framework'

Is Windows Azure compatible with the .NET 2.0 framework?

做~自己de王妃 提交于 2019-12-20 01:11:33
问题 I have a service that was developed in the .NET 2.0 framework. It is installed in several sites and works with my application. I would like the service to be able to "report" back to me with certain information about the application. I wanted to see if Windows Azure would be an option for me to be able to store reports in a cloud db and be able to pull them when I need to. One of my main concerns is it compatible with my .NET 2.0 service? Thank you. 回答1: In a word: yes. Windows Azure can run

Attaching events to an TextBox underlying for a DataGridView cell

╄→гoц情女王★ 提交于 2019-12-19 21:56:31
问题 Is there any way to get underlying control for a DataGridView cell? I would like to attach normal texbox events to capture keystrokes and capture value changed. So i have 4 columns, each of them contains number of cells and all cells in one row should be handled different way based on its type. Basically i need my events to be fired only when a cell is being edited. 回答1: Subscribe the DataGridView.EditingControlShowing event, then subscribe the TextBox event you need. Example with TextBox

When would I use an AppDomain?

北城余情 提交于 2019-12-19 17:50:26
问题 I'm fairly new to reflection and I was wonder what I would use a (second) AppDomain for? What practical application would one have in a business application? 回答1: There are numerous uses. An secondary AppDomain can provide a degree of isolation that is similar to the isolation an OS provides processes. One practical use that I've used it for is dynamically loading "plug-in" DLLs. I wanted to support scanning a directory for DLLs at startup of the main executable, loading them and checking

When would I use an AppDomain?

主宰稳场 提交于 2019-12-19 17:49:07
问题 I'm fairly new to reflection and I was wonder what I would use a (second) AppDomain for? What practical application would one have in a business application? 回答1: There are numerous uses. An secondary AppDomain can provide a degree of isolation that is similar to the isolation an OS provides processes. One practical use that I've used it for is dynamically loading "plug-in" DLLs. I wanted to support scanning a directory for DLLs at startup of the main executable, loading them and checking

How to remove elements from an array

会有一股神秘感。 提交于 2019-12-19 10:22:12
问题 Hi I'm working on some legacy code that goes something along the lines of for(int i = results.Count-1; i >= 0; i--) { if(someCondition) { results.Remove(results[i]); } } To me it seems like bad practice to be removing the elements while still iterating through the loop because you'll be modifying the indexes. Is this a correct assumption? Is there a better way of doing this? I would like to use LINQ but I'm in 2.0 Framework 回答1: The removal is actually ok since you are going downwards to zero

How to inject method to auto property in .Net Framework

谁说我不能喝 提交于 2019-12-19 10:05:21
问题 I have some class Foo with many properties: public class Foo { public int Property1 { get; set; } public int Property2 { get; set; } public int Property3 { get; set; } } In other class I have some method, e.g. public void SomeMethod() { //... } How to inject this method to every setter of properties in the class Foo? I use .Net Framework 2.0 回答1: I don't think there is a way to do that at runtime with reflection. What you would probably want to do is use an AOP (aspect-oriented) approach, but

How to handle concurrent file access with a filestream/streamwriter?

情到浓时终转凉″ 提交于 2019-12-19 08:57:02
问题 I am writing an audit file that is writing the username, time, and the old/changed values of several variables in the application for each user when they use my application. It is using a FileStream and StreamWriter to access the audit file. All audits for each user will be written to the same file. The issue is that when two users are updating this audit file at the same time, the "old value" of each of the variable is mixing up between the users. Why is this and how can you solve the