4,439 Posted Topics

Member Avatar for laghaterohan

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 …

Member Avatar for ddanbe
0
116
Member Avatar for RehabReda

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.

Member Avatar for serkan sendur
0
143
Member Avatar for serkan sendur
Member Avatar for DdoubleD
1
846
Member Avatar for ddanbe

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; …

Member Avatar for ddanbe
0
144
Member Avatar for Dajer

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".

Member Avatar for ddanbe
0
119
Member Avatar for nikiarora

Have you already written down something on paper how you should do it?

Member Avatar for ddanbe
0
28
Member Avatar for papanyquiL

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 …

Member Avatar for papanyquiL
0
146
Member Avatar for Dajer

When I do the same I get ____/__/__ I typed zeros, I assumed you did too.

Member Avatar for ddanbe
0
85
Member Avatar for atx
Member Avatar for arunkumars

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.

Member Avatar for arunkumars
0
126
Member Avatar for san_crazy
Member Avatar for ddanbe
0
721
Member Avatar for z_zendegi
Member Avatar for lorenb

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]

Member Avatar for sknake
0
136
Member Avatar for ddanbe

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 …

Member Avatar for DdoubleD
1
121
Member Avatar for afr0

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 …

Member Avatar for ddanbe
0
2K
Member Avatar for vinnijain

[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) …

Member Avatar for ddanbe
0
223
Member Avatar for ashley1234

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 …

Member Avatar for sknake
0
78
Member Avatar for dunk00

Why would anyone turn a working forms application, which can have all the whistles and bells you want, into a console application?

Member Avatar for DdoubleD
0
171
Member Avatar for avirag

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.

Member Avatar for ddanbe
0
339
Member Avatar for Ancient Dragon

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:*

Member Avatar for Wasser
1
232
Member Avatar for ddanbe

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]

Member Avatar for ddanbe
0
111
Member Avatar for tmantix

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 …

Member Avatar for tmantix
0
159
Member Avatar for scranton
Member Avatar for Alexar93

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 …

Member Avatar for ddanbe
0
101
Member Avatar for vinnijain

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. …

Member Avatar for vinnijain
0
244
Member Avatar for kbarrett

perhaps this [url=http://www.developers.ie/ShowArticle.aspx?id=68f4a406-ee04-44ce-92ed-208c97d22e9a]intro to printing[/url] will help.

Member Avatar for DdoubleD
0
5K
Member Avatar for avirag
Member Avatar for ddanbe
0
537
Member Avatar for ddanbe

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; …

Member Avatar for ddanbe
0
103
Member Avatar for arelius

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. …

Member Avatar for arelius
0
2K
Member Avatar for getkiran1

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.

Member Avatar for Diamonddrake
0
232
Member Avatar for deepugtm

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 …

Member Avatar for darkocean
0
144
Member Avatar for 666kennedy

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 …

Member Avatar for ddanbe
0
144
Member Avatar for Geekitygeek

Don't know if it helps, but have you ever tried to remove(comment them out) all the Dispose methods from your Draw method?

Member Avatar for ddanbe
0
119
Member Avatar for 666kennedy

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 …

Member Avatar for wildgoose
0
267
Member Avatar for BobLewiston

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 …

Member Avatar for DdoubleD
0
100
Member Avatar for Ancient Dragon

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.

Member Avatar for crunchie
0
189
Member Avatar for snakay

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]

Member Avatar for snakay
0
92
Member Avatar for thanatos1
Member Avatar for Dmennite

Perhaps you could change [url=http://www.daniweb.com/code/snippet1094.html]this[/url] to what you need.

Member Avatar for Dmennite
0
201
Member Avatar for darab

You will have to intercept all the mouse and keyboard events. Then you can set everything to your liking.

Member Avatar for darab
0
126
Member Avatar for ddanbe

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 …

Member Avatar for sknake
0
77
Member Avatar for happygeek

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!

Member Avatar for ddanbe
0
186
Member Avatar for amgupt01

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 …

Member Avatar for sknake
0
184
Member Avatar for Dimansu

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"?

Member Avatar for darkocean
0
87
Member Avatar for vinnijain

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 …

Member Avatar for vinnijain
0
169
Member Avatar for buddyholly
Member Avatar for ddanbe
0
701
Member Avatar for darab

You can try [url=http://www.daniweb.com/code/snippet1094.html]this snippet[/url]

Member Avatar for sknake
0
150
Member Avatar for snakay

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.

Member Avatar for snakay
-1
251
Member Avatar for javac#

[url=http://www.ebook-x.com/free-c-ebooks/]This site?[/url] BTW welcome on this C# formum!

Member Avatar for ddanbe
0
79
Member Avatar for avirag

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.

Member Avatar for avirag
0
104

The End.