376 Posted Topics
Re: In your first listing, the variables you defined are local to the Main method and work as they should, as you have seen. In the second example, the variables are instance members of the class. Main, however, is a static method, which means it simply applies to calctest, not individual … | |
Re: Average Joe cannot download XNA, copy/paste from tutorials, and make a "Triple A" game. Average Joe can download XNA, fool around with it, and go back to playing Call of Duty after he realizes he can't program for squat. Motivated Novice can download XNA, put together the worst code imaginable, … | |
Re: [CODE] using System; class Program { static void Main(string[] args) { Foo foo = new Foo(); foo.Blah = 17; Foo foo2 = new Foo(); foo2.Blah = 36; foo.CompareTo(foo2); // uses IComparable<Foo> implementation ((IComparable)foo).CompareTo(foo2); // uses IComparable implementation } } public class Foo : IComparable<Foo>, IComparable { public int Blah { … | |
Re: What if the Queen is overthrone beforehand? Hmmm? ![]() | |
I work for a small company that develops websites for other companies, most of them local, some with a more regional or semi-national presence. I cannot tell you how many websites I've worked on where some guy has an idea and just barely enough cash to pay someone to develop … | |
[CODE] int[][] jaggedArray = (from line in File.ReadAllLines(fileName).Skip(1) select (from item in line.Split('\t').Skip(1) select int.Parse(item)).ToArray()).ToArray(); [/CODE] This is a crazy example. It was sparked by what is probably a homework thread on another forum here, but it is basically reading in a tab-delimitted text file, stripping out the first row … | |
Re: You've asked this question before. You said you figured it out before. What has changed? As I said one of the other times, I gave you sample code for working with a generic list of Button objects. List<T>, where T can be any type you can come up with. ints, … | |
Re: Show the code for how you're consuming the class. A couple of items, though. 1) The program looks more like a Java program. Are you of a Java background (or perhaps is your teacher)? In C#, we use Pascal-casing to name methods. Basically, the first letter of each word is … | |
Re: [CODE] static void Main(string[] args) { int[] array = new int[] { 1, 2, 3 }; DoSomething(ref array); foreach (int value in array) Console.WriteLine(value); Console.Read(); } static void DoSomething(ref int[] array) { array = new int[] { 2, 4, 6, 8, 10 }; } [/CODE] | |
Re: It's not all that difficult, and is much easier if you have a firm grip on LINQ and extension methods. But first, [I]what have you tried? [/I] To start, I would suggest reading the contents of the fille using the File.ReadAllLines(fileName) method (System.IO namespace). That will read the contents of … | |
Re: Actually, I'm quite pleased with my current laptop, although I wish Windows 7 loaded faster. On the other hand, I don't play games on my computer, I stick to consoles. | |
Re: More than likely it is a matter of the process not having write access to the folder where your Access database is located. Check user/folder permissions on the server. | |
Re: The immediately visible error is the use of an unassigned local variable (input). Once that is fixed, you have the critical error of your code simply not working. | |
Re: I provided an example working with a generic list of buttons, the "Button" being a common winform control. If you're using something other than the regular button, obviously List<Button> will not work. Make it List<[I]WhateverTheTypeYouNeed[/I]> instead. Search google and read up on generic collections in .NET and C#. But the … | |
Re: Is this the same user as trippinz? Anyway, in the hypothetical scenario that you have all the textboxes stored in a List<TextBox> structure, you could do something like this. [CODE] // using statement: using System.Collections.Generic; List<TextBox> boxes = new List<TextBox>() { textBox1, textBox2, textBox3, textBox4, textBox5 }; // etc. // … | |
Re: Show us what you've tried! Did the example I provided [URL="http://www.daniweb.com/forums/thread266791.html"]here [/URL]give you a good start? And is this homework, work-related, etc.? | |
Re: To expand on what Narue has provided, here's a way to capture the information and format it and then clear the textboxes. Uses Linq, extension methods, etc. [CODE] var controls = this.Controls.Cast<Control>(); string[] texts = (from control in controls where control is TextBox select control.Text).ToArray(); StringBuilder builder = new StringBuilder(); … | |
Re: Here's a slimmed down example of what I think you're looking for. I've created a form, 5 textboxes, 5 buttons. For the purposes of this example, the 5 values of note are A, B, C, D, and E. [CODE] using System; using System.Collections.Generic; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial … | |
Re: Functionally, a simple text file is far different than a Word document. But as for creating a simple file, here is another method. [CODE] string[] temp = new string[] { "Apple", "Banana", "Cherry" }; string fileName = @"C:\Temp\junk.txt"; File.WriteAllLines(fileName, temp); [/CODE] Which would create a text file that looks like … | |
Re: XmlValidatingReader looks like it was phased out in the transition from .NET 1.1 to 2.0. Look at using XmlReader.Create() along with an XmlReaderSettings object instead. | |
Re: @ddanbe It hurts to have to correct you! But Juha's code does return 10 for i. The overload he used will return the portion of the string from starting index specified (1) all the way until the end of the string. | |
Re: Consider this modification of your code. [CODE] public string[] SelectTable(String pSqlstmt) { string str = null; // you declared this variable before but did not use it if (pSqlstmt.Contains("from")) { int strlen = pSqlstmt.Length; int strindfrom = pSqlstmt.IndexOf("from"); if (pSqlstmt.Contains("where")) { int strindwhere = pSqlstmt.IndexOf("where"); str = pSqlstmt.Substring(strindfrom, strindwhere); } … | |
Re: You're comparing various parts of each line to each other (it appears), but if you want to see if the entire lines are equal, why not just compare the entire lines? A quick way to achieve this would be to use a static method of the type File to read … | |
Re: What he means is that you established an array, but each element of the array is still null. You need to create instances of Point at each element before you can access any members. | |
Re: I would step through the code and make sure it is doing what you think it should be doing. I can run your code on a smaller file, and a StringBuilder should be able to handle the number of "words" you're trying to throw at it, it can hold over … | |
Re: I would suggest LINQ to XML. You can easily load the XML file into a IEnumerable<> of either a defined or anonymous type and then combine your elements however necessary for your output. Given the following file format: [CODE=XML] <?xml version="1.0" encoding="utf-8" ?> <rows> <row> <UDPName>10014535-Test</UDPName> <SpeedDialIndex>2</SpeedDialIndex> <Label>mobile</Label> <SpeedDialNumber>907********</SpeedDialNumber> </row> … | |
Re: You've got a cartesian join. You're selecting multiple tables into your query without providing a joining statement to link the tables together based on 1 or more common fields. As a result, each row of each table is being combined with each row of the other tables so as to … | |
Re: You did have an extra bracket, but you also had a class and functions dropped within your main method where you had copied/pasted the web code. Here is a fixed format you can continue to work on (not guaranteed to work as is, I only fixed your formatting issues). [CODE] … | |
Re: It looks like you are filling a datatable within the dataset that already exists. You're reusing the same datatable, is that correct? You need to either clear the existing data from that datatable or remove the datatable from the dataset altogether before you call the Fill operation again. [CODE] ds.Tables.Remove("yourDataTableNameHere") … | |
Re: [CODE] Dim myDate As DateTime = DateTime.Now Dim dateFormat As String = "d-MMM-yy h:mm tt" Console.WriteLine(myDate.ToString(dateFormat).ToLower()) [/CODE] Output: 11-mar-10 10:13 am | |
Re: To strip everything following the first instance of '<script', you could use something like this. [CODE] update temptable set tempfield = LEFT(tempfield, charindex('<script', tempfield, 0) - 1) where tempfield like '%<script%' [/CODE] | |
Re: You should be getting an ArgumentOutOfRangeException on this. [CODE] for (int i = 0; i < infixExp.Length; i++) { str = infixExp.Substring(i, i + 1); [/CODE] Your substring length (i + 1) is getting progressively longer with each iteration, and it won't be too many iterations before the length exceeds … | |
Re: @youdester This thread is over 3 years old! If you have some code you'd like to share, you can start a new thread. Just be sure to use code tags to wrap your code. (See the (code) button). On that note, consider this example to streamline what you are doing. … | |
Re: If your website is on Windows hosting, chances are you have the ability to utilize ASP.NET, which would allow you to write web pages/applications in C#/VB running on top of the .NET framework. You'd have to check with your service provider. | |
Re: Change onclick to onserverclick and it will work as you intend. | |
Re: When you do a for each and remove controls from the collection you're iterating over, it creates problems like the one you're having. Say if you have a list like item1 item2 item3 You do a for each loop over the collection and remove the first record and then move … | |
Re: Can you post the code that is calling that particular function? My hunch is that your datetime argument is invalid. | |
Re: [QUOTE=kerek2;1150499]Hi, i need your help to get date of birth (DOB) from the Age that given...example AGE = 45...so how to get the DOB?...tq[/QUOTE] You're not going to get a precise date of birth if all you have is the integer age. You may be able to get reasonably close … | |
Re: Canada's got other things going for it, too. For example, they're closer to Santa. | |
Re: What have you tried? Each different control is going to have different events available, and I won't even try to go through the list of them. For any given control you want to test, there's nothing better than simply going to google, typing in the control name, and usually that … | |
Re: I would consider an XML format. [CODE] <?xml version="1.0" encoding="utf-8"?> <Quiz> <Question> <QuestionText>What date was time travel invented?</QuestionText> <Answer>July 4, 1776</Answer> <Answer>December 7, 1941</Answer> <Answer>August 16, 1977</Answer> <Answer Correct="true">November 5, 1955</Answer> </Question> <Question> <QuestionText>How much power is required for the flux capacitor to work?</QuestionText> <Answer>4 Palpatines</Answer> <Answer>3 Vaders</Answer> <Answer Correct="true">1.21 … | |
| |
Re: Have you tried using a Random object? Perhaps consider generating a random number between 0 and the number of items in the ListBox control. With that number, you can select an item and use that to populate the TextBox. | |
Re: The error message indicates that you are using a RadioButtonList control instead of a standard RadioButton. To access the item that is selected in the control, you can utilize the .SelectedItem property (be careful, it can be null if the user has not made a selection) or to simply get … | |
Re: If I can even think back that far (it has been so long), but I [I]believe [/I]it was a post on a C# prime number algorithm. Good times. I was such a different person then, I barely recognize myself. | |
Re: I don't believe there's a simple single-query method of constructing your list. You can accomplish it using a programming language of your choice, or you can use a procedure in SQL Server to produce your output. The below is not going to translate exactly for you, but it should give … | |
Re: You haven't defined the LargeCoins(), MediumCoins(), and SmallCoins() methods. Calling them within the loop and within the if blocks will work. One issue you presently have is that there is nothing within the loop to eventually bring about an exit condition. As such, and once you define the aforementioned methods, … |
The End.