- Strength to Increase Rep
- +11
- Strength to Decrease Rep
- -2
- Upvotes Received
- 198
- Posts with Upvotes
- 153
- Upvoting Members
- 59
- Downvotes Received
- 5
- Posts with Downvotes
- 5
- Downvoting Members
- 5
I am a web developer that deals mostly in .NET and C#. My prior background was working in VB6 and VBA. I know my way around data and code, but I'll not pretend to know as much as I want to know.
- Interests
- Programming! Music and video games.
- PC Specs
- Dell Studio 17 laptop running Windows 7, plenty powerful enough for my needs.
376 Posted Topics
Re: I went out for a salad for lunch, came back with a stromboli. Hey, it happens. Washing it down with a nice, tasty Coke. | |
Re: [CODE] List<int> list = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; Random random = new Random(); var sortedList = list.OrderBy(i => random.Next()).ToList(); foreach (int i in sortedList) Console.WriteLine(i); // split list into 2 var group1 = sortedList.Take(5); var group2 = sortedList.Skip(5).Take(5); Console.Read(); [/CODE] | |
Re: In VBA, there is/was an ActiveCell.Offset method, but it was more complicated than that. It would be ActiveCell.Offset(rowcount, columncount).Range("A1").Select. The "A1" was sort of like a grounding value, giving it the proper frame of reference. That may or may not be proper description for it, but I knew whenever I … | |
Re: [CODE] Type type = Type.GetType("WindowsFormsApplication1.Form2"); object obj = Activator.CreateInstance(type); (obj as Form).Show(); [/CODE] | |
Re: [QUOTE=jazz_vill;1120831]Ok here's my code: is there another way to improve this code? so I dont have to this routine in every letter?[/QUOTE] The ASCII values for A-Z are 65 to 90. You could loop over those integers to search for your characters. Easier still, you could create a string of … | |
Re: Does this proof of concept fit your needs? [CODE=C#] static void Main(string[] args) { string fileName = @"C:\Work\test.bmp"; string fileNameCopy = @"C:\Work\test2.bmp"; Byte[] buffer = File.ReadAllBytes(fileName); MemoryStream stream = new MemoryStream(buffer); try { File.Delete(fileName); Console.WriteLine("Original file deleted."); } catch { throw ; } Bitmap bitmap = (Bitmap)Bitmap.FromStream(stream); bitmap.Save(fileNameCopy); bitmap.Dispose(); stream.Dispose(); … | |
Re: Here's a way of doing it. It involves creating a public function to update the list data in your main form, and creating a constructor overload in the second form to accept a parameter of the type of the main form. Then on a button click event on the second … | |
Re: [CODE] Dim result As DialogResult = MessageBox.Show("Some text", "Some caption", MessageBoxButtons.OKCancel) If result = Windows.Forms.DialogResult.OK Then 'do something ElseIf result = Windows.Forms.DialogResult.Cancel Then 'do something else End If [/CODE] | |
Re: You should probably look at writing a web service. Create the service on your website, add a reference to it in your offline project (it will generate the proxy classes you need), and then you can interact with it. Here's a sample web service implementation: [CODE] using System.Collections.Generic; using System.IO; … | |
Re: Here is a method to read it using LINQ to XML (System.Xml.Linq). This will create an IEnumerable(of T), where T is an anonymous type. [CODE] Sub Main() Dim xml As String = "<?xml version=""1.0"" encoding=""utf-8""?>" _ & "<pupil>" _ & "<name>Test Name</name>" _ & "<tagid>00000000000000000001</tagid>" _ & "</pupil>" Dim document … | |
Re: You can use reflection to load an assembly at runtime. Consider this code compiled into Foo.dll [CODE] namespace Foo { public class Bar { public string Blah() { return "Blah"; } } } [/CODE] And then in another program [CODE] using System; using System.Reflection; class Program { static void Main(string[] … | |
Re: This is the first I've heard of this, but stackoverflow says it happens when you use the publish utility within Visual Studio. I have no idea if that's true or not. [url]http://stackoverflow.com/questions/2148125/why-does-app-offline-htm-keep-appearing-in-my-web-project[/url] From a link off that link, there's also this blurb "SQL Server 2005 express edition does not support … | |
Re: I don't know how applicable this may be, but it's interesting nonetheless. Here's an article on using GDI+ and doing color transformations with a matrix of floats. [url]http://www.aspfree.com/c/a/C-Sharp/Performing-Color-Transformation-Operations-in-Csharp-GDIplus/[/url] I also don't know of any (other) methods to tweak colors besides, as you said, simply messing with the RGB values. As … | |
Re: Right now, I'm listening to a compilation of various Royksopp tracks off the Melody AM, The Understanding, and Junior albums. | |
Re: My algorithm below is similar to what slogfilet suggested: I consider using anything beyond the square root of the integer candidate to be redundant and a waste of time to use as a test divisor. I'm not accepting user input, nor am I writing the prime numbers to the screen, … | |
Re: DataGrids, Repeaters, etc., do not have to be used with database connections, they can be bound with other collections. Take this example: [CODE] <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!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" runat="server"> <div> <asp:DataGrid … | |
Re: Your assumption is correct. [CODE]StringBuilder[] empDetails = new StringBuilder[100];[/CODE] This line establishes an array of StringBuilder references, but you still need to create instances of objects for each array element (*or at least any element you intend to actually use). [CODE] for (int i = 0; i < empDetails.Length; i++) … | |
Re: I use IE mostly, FF occasionally (usually just to test something). IE meets my needs. | |
Re: 1) Don't assume the input should be an integer. If you want to calculate the number of coins required, you should allow for dollars [I]and[/I] cents. Use a [ICODE]double[/ICODE] or [ICODE]decimal[/ICODE] data type instead. 2) For validation, use the .TryParse(string input, out result) method. The method itself returns a bool, … | |
Re: Here is an example using an order table. You take the top 1 from the top N [I]in reverse order[/I]. [CODE] select top 1 OrderTotal From (select top 10 OrderTotal from orders order by ordertotal desc) x Order By x.OrderTotal [/CODE] Let's say my top 10 OrderTotals (in descending order) … | |
Re: [CODE] sql = "SELECT * FROM tblBookings WHERE StudentID = " & Target And "Paid =" & Target2 [/CODE] The word [I]And[/I] should be inside your quotes. [CODE] sql = "SELECT * FROM tblBookings WHERE StudentID = " & Target & " And Paid = " & Target2 [/CODE] And … | |
Re: Is there a reason you want to convert the pages from programmable ASP.NET to static HTML? I would use a URL rewriting solution instead to get all the programmability of ASP.NET while also having SEO-friendly URLs. There are canned solutions available (built into IIS7 or you can use a tool … | |
Re: My favorite game of recent months is Dragon Age: Origins, which I played on Xbox 360 but it also available on PC and PS3. Mass Effect 2 (360 and PC) is also a good recent game. All time? I'm going with Star Wars: Knights of the Old Republic. [I]This post … | |
Re: That reminds me of a video from a few years ago that has unfortunately been taken down from youtube and I can't find it elsewhere. The short version is that a guy tied a rope to his truck and dragged a GameCube along the road for several miles, with it … | |
Re: I had a Mazda Protege once. It was a good little car; it had 225,000 miles on it when I traded it in towards a new car a few years ago. This was a 1994 Protege, so I can't attest to current quality, but that one served me well. | |
Re: I went to a doctor for medical advice and a healthy eating recipe. He gave me green eggs and spam. Should have known not to go to Dr. Seuss. | |
Re: I think a good time to have pasta would be during breakfast. Would you agree, ana12? | |
Re: [QUOTE=GrimJack;1102621]Most common computer problem is the interface between the chair and the keyboard[/QUOTE] Ah, ye olde PEBKAC error. | |
Re: I wouldn't use a repeater to generate XML, but that's just me. If you want to continue down that path, I would advise you to explore the repeater's ItemDataBound event and take care of the binding of the second repeater within the code behind of the page. As for another … | |
Re: sir i want you to show some effort and [URL="http://www.daniweb.com/forums/announcement58-2.html"]read the rules[/URL] | |
Re: I suggest a new strategy. Let the girl win. | |
Re: You can use LINQ to XML (System.Xml.Linq namespace) to parse the XML file. [CODE] string xml = @"<rsp stat=""ok""> <photos page=""1"" pages=""8951"" perpage=""100"" total=""895061""> <photo id=""4503248539"" owner=""33965274@N08"" secret=""b60e5fcc27"" server=""2774"" farm=""3"" title=""alright, tia"" ispublic=""1"" isfriend=""0"" isfamily=""0""/> <photo id=""4503259303"" owner=""49065542@N00"" secret=""1765234706"" server=""4053"" farm=""5"" title=""French Bulldog"" ispublic=""1"" isfriend=""0"" isfamily=""0""/> <photo id=""4503856822"" owner=""33703729@N08"" secret=""36e52001bc"" … | |
Re: Try casting the left side. [CODE] if((bool)dataGridView1.Rows[i].Cells["Checked"].Value ==true) [/CODE] | |
Re: Did not read the whole thread, but about the Next(0, 1), if you read the intellisense documentation, you should notice that the second parameter (the 1, in this case) is the *exclusive* upperbounds. You are in essence asking for a random integer between 0 and 0. If you want 0 … | |
Re: [CODE] // given array and filename string[] array = { "apple", "banana", "cherry" }; string filename = @"C:\Temp\arrayfile.txt"; // short version using (StreamWriter writer = new StreamWriter(filename)) { foreach (string item in array) writer.WriteLine(item); } // short, short version File.WriteAllLines(filename, array); [/CODE] | |
Re: [CODE] // option 1, use where clause to filter and AddRange to append non-null items to existing list List<Example> list = new List<Example>(); list.AddRange(data.Where(item => item != null)); // option 2, use where clause to filter data and then convert to list List<Example> list = data.Where(item => item != null).ToList(); … | |
Re: Here are two methods, one being a LINQ one-liner, the other being similar to Edward's with a dictionary. [CODE] static T GetMostFrequentWithLinq<T>(IEnumerable<T> list) { return list.GroupBy(val => val).OrderByDescending(grp => grp.Count()).Select(grp => grp.Key).First(); } static T GetMostFrequent<T>(IEnumerable<T> list) { Dictionary<T, int> dictionary = new Dictionary<T, int>(); int maxCount = 0; T … | |
Re: Look at the generic Func<TResult> delegate system. You can do something like this [CODE] class Program { static void Main(string[] args) { Func<int> function = GetFunction(); Console.WriteLine(function()); Console.Read(); } static Func<int> GetFunction() { return () => Foo(); } static int Foo() { return 1; } } [/CODE] For more info, … | |
Re: So just so we're clear, you have a string, you split it up into chunks of 4 characters each, but it's basically an array of strings? Why not just loop through the elements, test each one, and for each one that contains an illegal character, simply set the element equal … ![]() | |
Re: You have never created an instance of StreamWriter. Your declaration is [CODE]public static StreamWriter writer;[/CODE] In the IrcBot class, but you've never at any point said [CODE] writer = new StreamWriter(somepath); [/CODE] Or otherwise obtained a StreamWriter instance. Fix that error, give it another try, and report back if you … | |
Re: [CODE] DateTime.Now.ToString(); // want hours, minutes, seconds only? DateTime.Now.ToString("HH:mm:ss"); [/CODE] | |
Re: No, || and && will short circuit. In an ||, if the left hand side evaluates to true, there is no need to evaluate the right hand side. Similarly, if the left evaluates to false in an &&, the right also becomes a useless check. As such, each will short … | |
Re: Try something like [CODE] Random random = new Random(); int index = random.Next(0, array.Length); // list.Count for List<T> string value = array[index]; // where array is string[] [/CODE] | |
Re: If an object you use implements the IDisposable interface and has a Dispose method, you want to be in the habit of using it so the object can clean up its resources. The recommended way of doing so is to simply wrap the usage of the object in a using … | |
Re: If you could describe your problem a bit more. But in general, if you are adding reference types as keys, the comparison is going to be made between references rather than the unique nature of the information being referenced. For example, if I have a Hashtable where I am storing … | |
Re: Try something like this [CODE] static int GetSumOfPositiveValues(int[] array, int index) { int sum = 0; if (index < array.Length - 1) sum += GetSumOfPositiveValues(array, index + 1); if (array[index] > 0) sum += array[index]; return sum; } .. int[] array = { 10, -5, 5, -6, -9 }; int … | |
Re: Define a concrete type instead of allowing the query result to be anonymous. | |
Re: Sure, consider this example. [CODE] string input = "0008 0006 0007 0005 0003 0000 0009"; int[] array = input.Split().Select(s => int.Parse(s)).ToArray(); foreach (int i in array) Console.WriteLine(i); [/CODE] | |
Re: There may be a better method than this. In fact, I'm almost positive I've seen one, but here's an idea. This one uses .NET 4 and the new Tuple, but it can be easily adapted to use a concrete class or perhaps out parameters. [CODE] using System; using System.Collections.Generic; using … |
The End.