c#-3.0

C# Xml Serialization & Deserialization

不问归期 提交于 2019-12-28 04:08:30
问题 I am trying to serialize an object & save it into a Sql server 2008 xml field. I also have some deserialization code that re-hydrates the object. I am able to serialize & save the object into the db, but get a "Root element missing" exception. [XmlRoot("Patient")] public class PatientXml { private AddressXml _address = null; private EmergencyContactXml _emergencyContact = null; private PersonalXml _personal = null; [XmlElement] public PersonalXml Personal { get { return _personal; } set {

Creating a new instance of form1 and change that forms property

橙三吉。 提交于 2019-12-25 11:58:16
问题 In my current project, I am making a sticky-note type application in which the user can have multiple instances open of the same form. However, I was wondering if there was a way in C# where I can create a new instance of form1 however have the new form's title/text/heading to be form2. If this is achievable, I would like a nudge into the correct direction of how to code that part of my app. Thanks everyone. --EDIT-- I realized I forgot to add something important: I need to be able to

how to insert text from c# application into MS word document and save it as new file

末鹿安然 提交于 2019-12-25 08:42:50
问题 I have created a desktop application which in that I need to save texts of textbox into into a word document, the document should be created by user and the position of the document would be chosed by user and then the value of textbox should be saved into that. for example: "this is textBox value" then there is a save button, by clicking that the save window should be opened then user will give a name to that and set its position then click OK finally the text of textbox will be saved into

How to compare two richtextbox text using C#

巧了我就是萌 提交于 2019-12-25 08:39:20
问题 I have written a logic to compare two ricttext boxes content, but the output difference text is not highlighted at the expected index. It starts ahead of the expected index. I have given below the logic i have used. private void CompareRichTextContents(RichTextBox target, RichTextBox dest) { string[] targetLines = target.Lines; string[] destLine = dest.Lines; List<string> result=targetLines.Except(destLine).ToList<string>(); foreach (string str in result) { int lineIndex=Array.IndexOf

Validate a 10 digit ISBN Number ERD Included

走远了吗. 提交于 2019-12-25 07:46:44
问题 I'm trying to make a program that check the ISBN number and sees if it has the correct check digit, if it doesn't have the check digit it will add one. I have an Idea of how it will work I just cant figure out how to code for it as in the classes inheriting from each other. This is an in class example that is not going to be graded it is just to familiarize us with getting our designs to a working program. here's what I have so far mind you this is a simple console program. Code Updated

How to retrieve unicode data stored directly in non-unicode field as varchar format in sql server

我怕爱的太早我们不能终老 提交于 2019-12-25 04:53:37
问题 I have to create a C# application which displays unicode data in a textbox. But the SQL server column storage has varchar data which contains unicode data. But since varchar is non-unicode based it displays character strings like "????????". Well the problem i am facing is i cant change the column type as there are other dependent application running on it. 回答1: You cannot store Unicode data in varchar without a conversion to the column's collation. So, what was Unicode will be encoded

Using System.Reflection

丶灬走出姿态 提交于 2019-12-25 03:47:07
问题 Im loading an Exe into my application using Assembly.LoadFile(). From that is it possible to get the Method of a particular class from that EXE. Thanks in advance . 回答1: Try: var assembly = Assembly.LoadFile("C:\path-to-some-app.exe"); var desiredType = assembly.GetType("SomeNamespace.SomeClass"); var methodInfo = desiredType.GetMethod("MethodName"); 回答2: A number of things you can do with Reflection (Including constructors, method invocation etc.) Tutorial at : http://www.csharp-examples.net

How to get Processor Id from win32 processor

扶醉桌前 提交于 2019-12-25 03:38:23
问题 string strProcessorId = string.Empty; SelectQuery query = new SelectQuery("Win32_processor"); ManagementObjectSearcher search = new ManagementObjectSearcher(query); foreach (ManagementObject info in search.Get()) { strProcessorId = info["processorId"].ToString(); } Console.WriteLine(strProcessorId); Console.ReadLine(); it gives error for line strProcessorId = info["processorId"].ToString(); error is: Object reference not set to an instance of an object. how to remove this error 回答1: WMI

Cannot implicitly convert type

孤者浪人 提交于 2019-12-25 03:23:17
问题 I have the following function public Dictionary<DateTime, object> GetAttributeList( EnumFactorType attributeType, Thomson.Financial.Vestek.Util.DateRange dateRange) { DateTime startDate = dateRange.StartDate; DateTime endDate = dateRange.EndDate; return ( //Step 1: Iterate over the attribute list and filter the records by // the supplied attribute type from assetAttribute in AttributeCollection where assetAttribute.AttributeType.Equals(attributeType) //Step2:Assign the TimeSeriesData

How to check ComboBox.selectedIndexChange event is null or not

早过忘川 提交于 2019-12-25 02:44:06
问题 How can i check whether ComboBox.SelectIndexchanged Event does not holding any method. Here i am having methods to Add and Rovemo methods to and from ComboBox which can serve for any comboBox. public static void AddMethodToComoBox(EventHandler MetodName, ComboBox cbm) { if(cbm.SelectedIndexChanged==null) { cm.SelectedIndexChanged += MetodName; } } public static void RemoveMethodToComoBox(EventHandler MetodName, ComboBox cbm) { if (cbm.SelectedIndexChanged != null) { cbm.SelectedIndexChanged -