.net-2.0

FIFO/Queue buffer specialising in byte streams

老子叫甜甜 提交于 2019-12-17 23:18:43
问题 Is there any .NET data structure/combination of classes that allows for byte data to be appended to the end of a buffer but all peeks and reads are from the start, shortening the buffer when I read? The MemoryStream class seems to do part of this, but I need to maintain separate locations for reading and writing, and it doesn't automatically discard the data at the start after it's read. An answer has been posted in reply to this question which is basically what I'm trying to do but I'd

How to hold the invalid value for NumericUpDown after it loses focus?

会有一股神秘感。 提交于 2019-12-17 20:23:40
问题 In my project there is an UserControl which includes a NumericUpDown ctrl, and its valid value range is from 10 to 100 , so if user inputs 200 in NumericUpDown ctrl, then its value will changed to 100 automatically after the focus changed to other ctrl, it looks a little bit curious for customer, because they may click the OK button after input 200 in the NumericUpDown ctrl, they need a message box that tells them the value they input is not in the range. But the question is the value for

Search XML file for nodes with specific attribute value in .NET 2

五迷三道 提交于 2019-12-17 19:27:36
问题 I found answers for searching XML nodes using LINQ, but I am limited to C# with .NET 2. I want to open a single XML file (~50Kb, all simple text) and search for all <Tool> nodes with attribute name having a specific value. It seems like XmlDocument.SelectNodes() might be what I'm looking for, but I don't know XPath. Is this the right way and if so what would code look like? 回答1: You can use XPath in XmlDocument.SelectNodes such as: SelectNodes("//ElementName[@AttributeName='AttributeValue']")

Validating xml nodes, not the entire document

隐身守侯 提交于 2019-12-17 19:07:09
问题 I'm working with some xml 'snippets' that form elements down the xml. I have the schema but I cannot validate these files because they are not complete xml documents. These snippets are wrapped with the necessary parent elements to form valid xml when they are used in other tools so I don't have much option in making them into valid xml or in changing the schema. Is it possible to validate an element, rather than the whole document? If not, what workarounds could be suggested? I'm working in

Migrate VB.NET 2.0 Winform to 3.5 WPF

南楼画角 提交于 2019-12-17 18:47:09
问题 Is it possible to migrate a VB.NET Winform solution to a 3.5 WPF solution. If so, any suggestions how to do it? Thanks in advance! JFV 回答1: Microsoft is doing everything for us so that we have to throw away everything we've written 2 years ago. According to Josh Smith, Is there a way to convert Winforms application to a WPF application? No. Those two UI platforms are very different and there is no app which converts a WinForms app to a WPF app. Of course, this will not prevent you from

Why does a Web Service DataMember's Specified Attribute need to be set for int and Data but not for String

北城以北 提交于 2019-12-17 18:29:58
问题 I have created a web service via WCF. Then I exposed it as a web service to make it usable with a .NET 2.0 application. I created some DataContract with DataMember that could be used for by the exposed OperationContract. I notice that when I try to create DataClass to be passed in the web service that each DataContract attribute now has a partner "Specified" attribute for each member. For example: [DataContract] public class Sales { [DataMember] public int InvoiceNo; ... } When I create an

What use is the Tag property in .net

时光怂恿深爱的人放手 提交于 2019-12-17 18:28:21
问题 I have noticed the Tag properties with controls. Is it okay to use this to reference my custom objects, or should I stay away from it as it would require boxing and unboxing which has been mentioned as unsafe and is not recomended. TreeNode tn = new TreeNode (); CustClass o = new CustClass() o.number = 123; tn.Tag = o; class CustClass { public int number {get; set;} } 回答1: The purpose of the Tag property is for you to use it for any purpose you want. You can safely store anything in there you

How to use Reflection to Invoke an Overloaded Method in .NET

纵饮孤独 提交于 2019-12-17 17:42:38
问题 Is there a way to Invoke an overloaded method using reflection in .NET (2.0). I have an application that dynamically instantiates classes that have been derived from a common base class. For compatibility purposes, this base class contains 2 methods of the same name, one with parameters, and one without. I need to call the parameterless method via the Invoke method. Right now, all I get is an error telling me that I'm trying to call an ambiguous method. Yes, I could just cast the object as an

Improve data access layer select method Pattern

≯℡__Kan透↙ 提交于 2019-12-17 15:41:55
问题 Lately I find myself writing data access layer select methods where the code all takes this general form: public static DataTable GetSomeData( ... arguments) { string sql = " ... sql string here: often it's just a stored procedure name ... "; DataTable result = new DataTable(); // GetOpenConnection() is a private method in the class: // it manages the connection string and returns an open and ready connection using (SqlConnection cn = GetOpenConnection()) using (SqlCommand cmd = new

Fastest way to convert datatable to generic list

强颜欢笑 提交于 2019-12-17 12:08:37
问题 I have a data tier select method that returns a datatable. It's called from a business tier method that should then return a strongly typed generic List. What I want to do is very similar (but not the same as) this question: How do you convert a DataTable into a generic list? What's different is that I want the list to contain strongly-typed objects rather than datarows (also, I don't have linq avaiable here yet). I'm concerned about performance. The business tier method will in turn be