4,439 Posted Topics
Re: You could do it this way: [CODE=c#] public partial class Form1 : Form { public Form1() { InitializeComponent(); } // This is the square method // C# has no funtions // Watch out for overflow here int Square(int x) { return x * x; } // This is the Click … | |
Re: Perhaps [url=http://www.daniweb.com/code/snippet1012.html]this snippet[/url] will shed a light on how to pass methods(in this case math functions: Hi Scott;) ) as a parameter to other methods. | |
Re: Have you a SelectedListViewItemsCollection class, or is it missing in a compact framework? | |
Have looked around but I could not find an answer to this question. Is there a difference between these two field initialisations? Or does it really not matter and is it just a matter of style. [CODE=c#]class aClass { private int aField; public aClass() //default constructor { aField = 42; … | |
Re: If you know your string contains only words separated by spaces you could use: [CODE=c#]string Mystr = "This is a sentence."; string[] split = Mystr.Split(new Char[] {' '});[/CODE] Now split[1] would contain the word "is". | |
Re: Have you already written down something on paper how you should do it? | |
Re: The book that turned me on to C# a few years ago was [url=http://www.amazon.com/Beginning-Visual-2005-Express-Professional/dp/1590595491/ref=sr_1_2?ie=UTF8&s=books&qid=1251569353&sr=8-2]this one[/url] But now you have LINQ, ASP, WPF etc. with of course a plethora of books covering the subjects. For the moment I am reading [url=http://www.amazon.com/Practical-Numerical-Methods-Jack-Xu/dp/0979372534/ref=sr_1_1?ie=UTF8&s=books&qid=1251570187&sr=1-1]this book[/url] it has more to do with math than with … | |
Re: When I do the same I get ____/__/__ I typed zeros, I assumed you did too. | |
Re: If you did it in VC++ it must not be that hard to translate it to C# and then show us some code where you have problems with. | |
Re: You can have 1000 files in your project. But only one of them can contain a method called Main. | |
Re: If it does not enter your if, it can only mean that the variable [B]str [/B]is not contained in the variable [B]str1[/B] | |
Hi all, I was wondering why the following code compiles, with or without extra komma? My feeling is it should not be there, but apparently it does not matter. Any comments would be more then welcome. [CODE=c#]namespace ConsoleApplication1 { class Program { public enum months { jan = 1, feb … | |
Re: Your code is correct but it gives the value if cumulative is false. The excel example gives the value when cumulative is true. I don't have your function in my Excel version, just simlated it with a similar function and setting mu to zero and sigma to one. Hope this … | |
Re: [CODE=c#]for(int i = 0; i < operators.Length; ++i) { char[] a1 = operators[i].ToCharArray(); char op =a1[i];[/CODE] Your operators array is an array of strings with a Lenght of the number of operators in your textbox. All these strings have a Lenght of 1. At any one moment a1(also an array) … | |
Re: Don't know what you mean by SMS. I associate it with a cell phone. If you have VS C# 2008 Express it is very easy to create a project : Choose New Project... from the file menu. A window opens in which you can choose the kind of project you … | |
Re: Why would anyone turn a working forms application, which can have all the whistles and bells you want, into a console application? | |
Re: A division is in essence a repeated substraction. Write down how you would do a division with paper and pencil. Try to translate that in code. The modulus [B]%[/B] and the integer division [B]/[/B] operators might help you out here. | |
Re: Happy you are still doing well after 47 years of marriage! Wish you all the luck in the world! I still have 14 years to go to reach your status:* | |
Hi all, has anyone any idea why I get an InvalidOperationException in this case? [CODE=c#]Dictionary<char, bool> dict = new Dictionary<char, bool>(6); dict.Add('A', false); dict.Add('B', false); dict.Add('C', true); // this works dict['A'] = true; // foreach gives an InvalidOperationException foreach (KeyValuePair<char, bool> KV in dict) { dict[KV.Key] = true; }[/CODE] | |
Re: string x; x = console.readline(); if (x == "Hello"); > it says you can't compare strings. > Hmmm, I thought you could do the "==", but anyway: Your Hmmm is correct DdoubleD, The == is an overloaded operator in the string class. Because it is overloaded the compiler can translate … | |
Re: You have overridden the forms OnPaint event. | |
Re: Normally you cannot. C# is not compiled to native assembly by the compiler but to IL (Intermediate Language) This IL is translated by a JIT(Just In Time) compiler in instructions a computer can understand. I think this scheme was first implemented by Java. It makes your code as portable as … | |
Re: It is not [B]ur [/B]it is [B]your[/B].:@ If you litterally typed in the code of DdoubleD it is likely that it will give errors. Different names I guess. If you say you have an error, please state what kind of error. You will get the answer you need more quickly. … | |
Re: perhaps this [url=http://www.developers.ie/ShowArticle.aspx?id=68f4a406-ee04-44ce-92ed-208c97d22e9a]intro to printing[/url] will help. | |
Re: Watch [url=http://msdn.microsoft.com/en-us/vcsharp/bb798037.aspx]this video[/url] | |
Hi all, I'm trying to implement a C-style union in C#. Found things on the web, but I have a problem. Depending how I initialize the fields in the union I get different results. Can anyone tell me what am I doing wrong here? Here is my code: [CODE=c#]using System; … | |
Re: Set a mindate to 1.1.3000 Set a maxdate to 1.1.1900 Start a loop Read a date if date < mindate ---> set mindate = date if date > maxdate ---> set maxdate = date At the end of the loop you will have the max and mindate from your list. … | |
Re: I think the closest you can get to the thing you want is to use a FileSystemWatcher class. But that will only work when your program is active of course. | |
Re: C# together with the .NET environment and Visual Studio lets you develop an application very quickly. It gives a weird feeling in the beginning, it feels like you are out of control of everything. You must of course stay in control and know what you are doing if you want … | |
Re: Use something like this: [CODE=c#] string testStr = "123XYZ"; string leftStr = testStr.Substring(0, 2); // gives "12" string midStr = testStr.Substring(2, 3); // gives "3XY" string rightStr = testStr.Substring(testStr.Length - 4, 4);// gives "3XYZ"[/CODE] Perhaps you could make some methods from this and put them in a class of your … | |
Re: Don't know if it helps, but have you ever tried to remove(comment them out) all the Dispose methods from your Draw method? | |
Re: perhaps you could do it with one for less by using the Contains method: [CODE=C#]int[] a = new int[4] { 1, 2, 3, 4 }; int[] b = new int[3] { 5, 6, 3 }; bool c = a.Contains(b[2]);[/CODE] The boolean c should be true here because b[2]=3 and a … | |
Re: I am somewhat in the same position as you, I started about a year ago. Do ANYTHING you can imagine and that you would like to accomplish. I made a console calculator(look in the code snippets) and I also did a calculator that looks a bit like the one we … | |
Re: You are made out of the material that is part of why DANIWEB is a great place to be. Wish you all the best with your health. | |
Re: Value types can not become null. But C# has what is called nullable types. You define and use them like this : [CODE=c#] bool? MyNullableBool; double? MyNullableDouble = 0.0; MyNullableBool = null; MyNullableDouble = null;[/CODE] | |
Re: Perhaps you could change [url=http://www.daniweb.com/code/snippet1094.html]this[/url] to what you need. | |
Re: You will have to intercept all the mouse and keyboard events. Then you can set everything to your liking. | |
Suppose I have these classes : [CODE=c#] class Square1 ////////// { private int side = 0; //private field public Square1(int side) //constructor { this.side = side; } public int GetArea() //public method { return side * side; } } class Square2 ////////// { private int side = 0; //private field … | |
Re: You may be a failure as a human(which I doubt;) ) You certainly will not fail in the job that's offered to you. Seen examples of that. Succes! | |
Re: Unless you definitely need to store all your values in a single database, why not leave it as it is and make your application read out a directory, where all your separate data files are stored and make as many plots as you want? It is not because SQL databases … | |
Re: What do you mean exactly when you say [B]cmb1== 0[/B] Do you mean : the combobox is empty or the combobox contains a "0"? | |
Re: Get rid of the habbit of naming your variables a, b, c etc. Give meaningfull names to them. When you come back later to your code and you read something like [B]MyNumberOfCars[/B], it says more than just [B]c [/B]. Now you have to wonder, "What was that [B]c [/B]again?" Now … | |
Re: You cannot always convert an Int64 to an Int16. An Int16 can not be greater than 32768. | |
Re: You can try [url=http://www.daniweb.com/code/snippet1094.html]this snippet[/url] | |
Re: Hi snakay, welcome to DANIWEB. A DataGridView has a Rows property which is of type DataGridViewRowCollection. You could use that if you want. Usually I just index like this : [B]dataGridView[0, 2].Value = something...[/B] Which is the first cell of the third row. | |
Re: [url=http://www.ebook-x.com/free-c-ebooks/]This site?[/url] BTW welcome on this C# formum! | |
Re: So I know you want to parse expressions like [B]231*467[/B] (See [url]http://www.daniweb.com/forums/post938112.html#post938112[/url]) The easiest way here would be to use the string [B]Split [/B]method. |
The End.