376 Posted Topics
Re: I'd revisit that assumption, there could be something else incorrect in your code. Consider this example. [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { int buttonID = 0; for (int i = 0; i < 10; i++) { … | |
Re: You can persist values in a cookie, in session, or in viewstate. Here is a demo showing how to do this by using viewstate. [B]viewstatedemo.aspx[/B] [CODE] <%@ Page Language="C#" AutoEventWireup="true" CodeFile="viewstatedemo.aspx.cs" Inherits="viewstatedemo" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" … | |
Re: Look into arrays and generic lists. And to correct your wording, you do not have two classes of the same type. The [I]type[/I] is the [I]class[/I]. You have two [I]objects[/I] of the same type. The class is the definition, the object is the intantiation. | |
Re: Two things [CODE] if (x <= 22.5f) { } if (x >= 22.5f && x <= 67.5f) { } [/CODE] In statements like these, if the value is exactly 22.5f, then you're allowing control to enter each of these if statement. One way of stating intent is if one statement … | |
Re: Try out LINQ to XML. Give this sample a spin. [CODE] using System; using System.Linq; using System.Xml.Linq; class Program { static void Main() { string xml = @"<OUTPUT version=""2.0""> <RESPONSE> <LOAN_DATA loan_id=""xxxx"" loan_number=""1111"" loan_type=""HE"" status_code=""OK""> <![CDATA[<MORTGAGE_LOAN xmlns=""http://www.something.com/CLF"" version=""1.0""> <APPLICANTS> <APPLICANT is_declined=""N"" first_name=""MARISOL"" last_name=""TESTCASE"" m_initial=""L"" middle_name=""L"" ssn=""000000001"" > </APPLICANT> </APPLICANTS> </MORTGAGE_LOAN>]]> … | |
Re: \ is used to escape special characters in strings or chars. To use it normally, you either need to escape it (making it \\) or you can use the @ character in front of the entire string. [CODE] string oneWay = "C:\\Temp\\somefile.txt"; string anotherWay = @"C:\Temp\somefile.txt"; [/CODE] So for your … | |
Re: You can write a generic function to return whatever type is required of a function. Here is a simple example. [CODE] public T GetDefaultValue<T>(T input) { return default(T); } [/CODE] And using it [CODE] DateTime myDate = GetDefaultValue<DateTime>(); int myInt = GetDefaultValue<int>(); double myDouble = GetDefaultValue<double>(); string myString = GetDefaultValue<string>(); … | |
Re: You do not cast strings to int in such a manner. Your options boil down to these: [CODE]Convert.ToInt32([type] input) int.Parse(string input) int.TryParse(string input, out int result)[/CODE] Of these, the first 2 will throw exceptions if you do not provide a valid input that can be converted to an integer. The … | |
Re: That's some crazy multi-level grouping that you need to do, more than likely. And it's possible. Run the following sample based upon what you've already done: [CODE] string xml = @"<rows><row> <DNOrPattern>0444</DNOrPattern> <HuntList>HL-1104 C Capital</HuntList> <LineGroup>LG-1000-COREVM1</LineGroup> <RNAReversionTimeout>4</RNAReversionTimeout> <DistributionAlgorithm>Top Down</DistributionAlgorithm> <Member>20130</Member> </row> <row> <DNOrPattern>1015</DNOrPattern> <HuntList>HL-1104 B Ltd</HuntList> <LineGroup>LG-1000-COREVM1</LineGroup> <RNAReversionTimeout>4</RNAReversionTimeout> <DistributionAlgorithm>Top Down</DistributionAlgorithm> … | |
Re: You're saying this [CODE] foreach (Person search in Page) [/CODE] Which suggests Page should be something equivalent to an IEnumerable of Person. (List<Person>, IEnumerable<Person>, etc.). However, in your Page declaration and instantiation, you have this [CODE] private List<string> Page; ... Page = new List<string>(); [/CODE] Hence the error. You have … | |
Re: You do, of course, realize that at 7 digits and allowing 3 possible characters per digit, you're going to generate 2187 different "words." If you allow for 4 characters for 7 (pqrs) and 9 (wxyz), then you can get 3888 words. Here's something I quickly put together, and I'm even … | |
Re: You could try something simple like [CODE] int mathOperator = random.Next(1, 5); // gives value of 1-4 switch (mathOperator) { case 1: result = leftSide + rightSize; break; case 2: result = leftSide - rightSize; break; case 3: result = leftSide * rightSide; break; case 4: result = leftSide / … | |
Re: Start by opening your copy of Visual Studio or Visual Basic Express. Click on "Create Project" and choose "Console Application." Give it a descriptive name. Once you've gotten this far, type some code, then come back and post it if you've got more questions. | |
Re: Go with whatever seems readable to you. [CODE]return a == b && x == y; [/CODE] Is fine with me. Others might want to see something more like [CODE] if (a == b && x == y) return true; return false; [/CODE] Understand that the logical operation I wrote is … | |
Re: You will not need to specify virtual in B to override it in C. The virtual of A will cascade, essentially. Run the following sample: [CODE] using System; class Program { static void Main() { C c = new C(); c.Y(); Console.Read(); } } class A { public void X() … | |
Re: [QUOTE=jk451;1174835]Running it with the VS 2008 C# compiler, the exception that's thrown in the code actually never gets propagated...[/QUOTE] Your code is doing exactly what you have told it to do. During the creation of the ArgumentNullException, you created a DivideByZeroException. 1) The creation of the ArgumentNullException did not succeed … | |
Re: That looks like the code from an IL disassembler such as ILDADM (comes with Visual Studio), it would be in the program's manifest. What you're looking at are using statements. It translates to [CODE] using System; using System.Windows.Forms; using System.Drawing; [/CODE] If you'd like, you can do a google search … | |
Re: You need to be in the main thread to set the text. Try something like this modification of your code. [CODE] private void Form1_Load(object sender, EventArgs e) { Thread demo = new Thread(new ThreadStart(this.ThreadProc)); demo.Start(); SetText("Main thread"); } private void ThreadProc() { while (true) { Thread.Sleep(1000); SetText(DateTime.Now.ToString()); } } private … | |
Re: Use the TextChanged event. [CODE] Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged If (TextBox1.Text.StartsWith(TextBox2.Text)) Then TextBox2.BackColor = Color.LightGreen Else TextBox2.BackColor = Color.Salmon End If End Sub [/CODE] | |
Re: Use a Regex. [CODE] using System; using System.Text.RegularExpressions; class Program { static void Main() { string input = @"<JDF ID=""n20090409EQ0001"" Type=""Product"" JobID=""000004-01"" xmlns=""http://www.CIP4.org/JDFSchema_1_1"" Status=""Waiting"" Version=""1.3"" xsi:type=""Product"" JobPartID=""B30"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:scr=""htt://new.scr.url/abc"" Activation=""Active""......."; string pattern = "xmlns:.*?\".*?\""; MatchCollection matches = Regex.Matches(input, pattern); foreach (Match match in matches) Console.WriteLine(match.Value); Console.Read(); } } [/CODE] It … | |
Re: Modify your Students declaration to match the following: [CODE] Students info = new Students(); [/CODE] | |
Re: The first part of the query is retrieving the files in the given directory. The second part is a select projection that takes a given filename, loads an XDocument and retrieves all descendants of that document of a particular name. In terms of the delegate signature for the inner function, … | |
Re: You were not providing the proper method signature when you were attempting to override OnPreRender. The proper signature is the following [CODE=VB.NET]Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)[/CODE] Overriding with the invalid signature didn't work because there was nothing to override with that signature. Omitting "overrides" and accepting a different … | |
Re: 1) A short is not an 8-bit integer. short is Int16. 2) There could be a better method than this, but here's something you can do. [CODE] byte b = 208; char[] chars = Convert.ToString(b, 2).ToCharArray(); Array.Reverse(chars); b = Convert.ToByte(new string(chars), 2); Console.WriteLine(b); Console.Read(); [/CODE] | |
Re: That would probably ruin your night. And day. And week. | |
Re: You can do this with a pair of loops. Including whitespace, using statements, and console output, I've coded a full program to work with a fixed array of integers in 28 lines. I'll give you the general description of the looping structure, sort of like pseudocode, and you should see … | |
Re: Strings are immutable. When you have set a string equal to a value, that value does not change in and of itself. Rather, changes are returned in a [I]new[/I] string object. To see your changes, you would write something like [CODE] string str = "a"; str = str.Remove(0); [/CODE] | |
Re: You have an if statement without surrounding brackets, which means the next line of code following the if statement is the single embedded statement of the if condition. You have commented out the line directly following the if statement. That makes the [I]next[/I] statement the single embedded statement of the … | |
Re: You can place a content placeholder in the header area of your master page. That way child pages can choose to utilize that placeholder for items such as scripts, extra stylesheet references, etc., that may not be applicable to all pages. | |
Re: I tried your algorithm and it works, however I found that you need to increase your number of executions for it to deliver a really good shuffle. 5 iterations leaves a lot of cards in the same order as the original. I bumped it up to 100 to get a … | |
Re: Here's an idea. [CODE] using System; using System.IO; using System.Linq; class Program { static void Main(string[] args) { string fileName = @"C:\Temp\blah.txt"; var valueHolder = new { StringRow = File.ReadAllLines(fileName).First(), NumericRows = File.ReadAllLines(fileName).Skip(1).Select(line => int.Parse(line)).ToList() }; Console.WriteLine(valueHolder.StringRow); valueHolder.NumericRows.ForEach(number => Console.WriteLine(number.ToString())); Console.Read(); } } [/CODE] blah.txt [CODE=Text] Blah 27 5 1098 … | |
Re: Always let j be >= i so it doesn't cover old ground. [CODE] int maxIndex = 5; for (int i = 0; i <= maxIndex; i++) { for (int j = i; j <= maxIndex; j++) { Console.WriteLine("i = {0} j = {1}", i, j); } } [/CODE] | |
Re: Personally, I'm not a fan of PHP, but I don't really have a dog in the fight because I don't use Java, either, as my place of employment does .NET. All other things behind held equal, my "unofficial official do not try this at home" litmus test is what's in … | |
Re: Look at some of the responses there. oops... wrong link before... how about this one [url]http://www.daniweb.com/forums/thread268827.html[/url] | |
Re: 1) list[list.Count-1] 2) Is x a public property or is it a method? More info on your implementation, please. 3) for (int i = 0; i < list.Count; i++) 4) I think you know by now. | |
Re: Is ChapterNo a text or numeric data field? | |
Re: [QUOTE=domingo;1162317]hi i tried casting the object but it doesn't seem to help. it casted the timespan asd but it gives me more errors, can anyone please help me?[/QUOTE] Cast the object from the reader. Something like [CODE] if ((TimeSpan)rdr[blah] < asd) { } [/CODE] | |
Re: You can increase the size that you can upload by adding/modifying the httpRuntime element under system.web in web.config. Example: [CODE] <httpRuntime maxRequestLength="20000" executionTimeout="900" /> [/CODE] This will allow request streams of 20000 KB (to support large uploads) and bump the timeout of a page up to 900 seconds. | |
Re: Sounds to me like your textbox "txtStorageChargeFee" is not populated. On that note, do not count on a user entering a valid numeric value in your application. Do not assume the user is smart, observant, or benevolent. Assume the user is a malevolent idiot driven by malice or ineptitude and … | |
Re: The database forums are subforums within the web development forum area. Here's a link to MS SQL. [url]http://www.daniweb.com/forums/forum127.html[/url] As for your issue, try this link. [url]http://support.microsoft.com/kb/918685[/url] Also, you may need to (re)install the .NET framework. | |
Re: You need to instantiate the array before you can use it. Consider this example: [CODE] int[] myArray; myArray[0] = 10; // error: Use of unassigned local variable 'myArray' [/CODE] It should be something like: [CODE] int[] myArray; myArray = new int[5]; // instantiate array myArray[0] = 10; [/CODE] | |
Re: Under no circumstances. [url]http://www.daniweb.com/forums/announcement58-2.html[/url] | |
Re: You need to call the .Add method instead of trying to set the List to the string. You have the .Add method in your property setter, but that's not going to be called with your given syntax. | |
Re: You can use static methods of the class File to create a file and write text. You can also create an instance of the class StreamWriter to create and write to a file. Both are in the System.IO namespace. Here is a usage example of both. [CODE] Imports System.IO Module … | |
Re: System.Data.ADO does not exist. The article you linked to was written in 2001 when .NET was still in beta. The final release and subsequent releases use objects in other namespaces. As adatapost said, you should use objects within a namespace that is specific to your database connection type. If you … | |
Re: [CODE] Dim value As Integer = 6 Select Case value Case 1, 2, 3 MessageBox.Show("Blah") Case Else MessageBox.Show("Errr") End Select [/CODE] | |
Re: Look at using File.ReadAllLines instead. It returns an array of strings for you. | |
Re: Theoretically, both could be valid. You could conceivably have a situation where you allow the modification of _field as long as _field is within a given range. Once it leaves that range, the field is essentially frozen. However, in the likely scenario, option 2 is more likely what you were … | |
Re: That's actually pretty good. You can turn the XML document into a jagged array of floats, but to my knowledge the only way to turn it into a true 2D matrix is to iterate over the result of the query. Here's my alternate code. [CODE] using System; using System.Linq; using … |
The End.