128 Posted Topics
I just got a first on my first assignment in C# programming... I would just like to say a massive thank you for everyone that has helped me out on here up to now and know that I really appreciate it. This site has helped me massively with problems and … | |
[CODE] TextReader myreader = new StreamReader; [/CODE] Is this inheritance...?? Thanks | |
Lets say i have this [CODE] Console.WriteLine "Enter your number or type exit and press enter to exit program"; string input = Console.ReadLine(); if (input == "exit") { break; } [/CODE] so my question is if you enter "exit" how do i get the console to exit? break just breaks … | |
Re: Hmmm..if you mean like swapping the values of your letter array to your number array and vice versa... put the values in to a new array..then swap them from that...i dont think there is a method in c# that actually does this...Maybe someone can clarify? (I would be interested to … | |
Re: you should take a look at the try catch finally statement. [url]http://msdn.microsoft.com/en-us/library/dszsf989(v=vs.71).aspx[/url] Without posting your code it is difficult to apply exception handling to it! | |
Re: Hi mate can you give some more info about exactly what your trying to achieve.. you have uneeded parts of code such as [CODE] string NumberAsString = System.Console.ReadLine(); int mark = Convert.ToInt32(NumberAsString); [/CODE] NumberAsString is in string format anyway so you can do these two lines in a single line... … | |
Re: OK...yeh thats not a bad assignment... You need to make a start yourself though... What code have you got so far? | |
Hi..... [CODE] private void button1_Click(object sender, EventArgs e) { Decimal[] mydecimal = new Decimal[10]; for (int i = 0; i < mydecimal.Length; i++) { mydecimal[i] += i; } foreach (Decimal mydec in mydecimal) { int count = 0; MessageBox.Show("I am button "+ Convert.ToInt32(count)+" in mydecimal"); count += count + 1; … | |
If I have [CODE] class Class1 { string message { get; set; } int age { get; set; } public Class1(string msg, int ageof) { message = msg; age = ageof; } [/CODE] and am passing the parameters from another class in to the constructor... [CODE] class Program { static … | |
Hi everyone... [CODE] Class1 myobject = new Class1(); [/CODE] Am I right in saying that "myobject" holds a copy of all the members in class1? Also say for instance I have.. [CODE] Class1 myobject = new Program(); //using the common names of classes... [/CODE] Can anyone explain or point me … | |
Re: [CODE] Form newForm = new winnerForm();//show if NAUGHTS wins - pass winner and score newForm.Show(); //call above then output a messagebox from winnerForm [/CODE] any good? | |
Hi everyone..... [CODE] class Program { private int price = 0; static void Main(string[] args) { Program instance = new Program(); Console.WriteLine("ENTER PRICE"); instance.price = Convert.ToInt32(Console.ReadLine()); } [/CODE] Ok so im learning...as you may have guessed... My question is..I know we should use getters and setters so we can shield … | |
| |
Re: Hmmm..just a simple problem here i think...say for instance num2 is returned as 5... The path to your .jpg file is say "\front5.jpg"... I believe if you put another two backslashes where i put the stars..you should be good to go...let me know.. [CODE] int num2 = randomNum(1,6); dice2PictureBox.Image = … | |
Hi, as I understand it, you can only access a static member from another static member? can anyone tell me how I would go about accessing a static member in a different class?? thanks.. also if anyone has any good links to sites about constructors..would be most grateful :-) | |
Hi everyone...just going from console apps to windows forms apps....This is extremely basic and is annoying me now... [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show("{0}",hello2(2)); } public int hello2(int hello) { hello = 10 / 5; … | |
Hi all...could anyone please tell me how when working with arrays you could use a forach loop to output the number of a certain item... for instance...if i wanted to find out the number of 5's in an array...could i use a foreach loop to find that out? Thanks | |
Re: Hi mate...the easiest way would be to make an array with your values... then declare another variable that will then hold the max number out of the numbers in your array. for example.... [CODE] //initilize your array of numbers... int[] myArray = {23, 58, 20, 19, 38, 12}; //now make … | |
| |
Hi everyone...I am at University and learning C# for my software development modules. Presently I am mostly using "Beginning Microsoft Visual C# 2008" (although I find C# for dummies pretty good!). Its always the case that some books suit people better than others and they find them easier to understand. … | |
Re: Hi mate...code seems to be fine...just put a curly brace to close the namespace and you should be good to go.... | |
Re: hmmm..you havent explained very well..can you post more of your code? | |
Re: .SubString will return the rest of the string from the element you specify onwards... Example: [CODE] string yourstring = "HELLO"; Console.WriteLine(yourstring.SubString(2)) [/CODE] in this case the output on the console would be LLO... Hope that makes sense? | |
If I have a variable in a try catch block the variable is only in scope within that try block...how can I then refer to this variable from the next try catch block? | |
Hi everyone.... [code] public void LoopGrades() { try//Start try block { //Start TextReader TextReader grades = new StreamReader("grades.dat"); ResultOfData = grades.ReadLine(); } catch (FileNotFoundException e) { MessageBox.Show("File Not Found!", "Error"); } //Loop through grades while (ResultOfData != null) { //ResultOfData is given the value that is read from grades.dat ResultOfData … | |
Hi there...im after a bit of adivce..I am doing an assignment that requires reading grades from a file...seeing how many grades there are of each and for higher marks outputting them to a html file in the form of a graph(instead of a graph to the console screen)... Could anyone … | |
Hi there just a quick question I am using C#Express. When I add the reference System.Windows.Forms I cannot seem to access Messagebox.Show...any ideas what I am doing wrong? Btw this is in a console application... | |
[code] class ReadGradesIn { public void readGrade() { int numberOfA = 0; //number of A grades int numberOfB = 0;//number of B grades int numberOfC = 0;//number of C grades int numberOfD = 0;//number of D grades int numberOfE = 0;//number of E grades int numberOfF = 0;//number of F … |
The End.