Answer Questions
Jim Hudson Value vs. Reference. When? Why?
Hello. I'm lost with some questions about types and performace. If i use strings (or another reference type) in a struct .. is struct more efficient than class in this case If i want create a string or another reference type collection ... is better ArrayList or List<string> If i have a struct that contains reference types, and pass it by value to a function ... the references are copied ... or the objects will be cloned When a struct that contains reference types ... is out of scope, whats happen With: struct MyExample { int MyInt; object MyObject; } MyExample Example; Are Example variable in the stack or because have a 'object' this part is in the heap Thanks in advance. Regards. The first thing to keep in mind is ...Show All
hommer try / catch question
Is it a good pratice to do the following void foo() { try{ ..... } catch(FileNotFoundException ex) { throw new FileNotFoundException(); } } void foo2() { try { foo(); } catch(FileNotFoundException ex) { .... } } Re throwing Eception is really expensive. Always try to make check where you think an exception can be thrown. U can Check File.Exists() so avoid Exception code even if it is thrown for some reason dont throw it again. Need more Information Best Regards In general, it's a really bad idea, mainly due to a problem whch Mario hinted at. Basically, when an exception is throw, stored within it is a listing of the current stack (which includes the list of methods called). If you c ...Show All
Disposalist Converting images to matrix form
Hi! I am currently doing a project on Locality-Sensitive Hashing. One query I have is whether is it possible to use C# to convert an image to a unique matrix of high dimensions. Any help would be greatly appreciated. Thanks for the quick reply. I am referring to whether an image could be described as a matrix in the form: (Image) => (x1, x2, ... , x61, x62); where xa is a positive integer. Gam What would you expect the obstacles to be How high is ‘high’, in ‘high dimensions’ What do you mean by ‘unique’ TonoGam, I don't know if this is what you mean, but you can convert a bitmap to an array of bytes. What follows is a ...Show All
Voltafil C# Threads
Hi, I have a problem with thread and i'm hoping someone can help me. I start a thread with the following code... Thread m_NewThread = new Thread(new ThreadStart(DoWork)); m_NewThread.Start(); The threaad starts find and executes the code within DoWork, for example: private void DoWork() { ... //Finished work so show thread finished ThreadFinished(); } Again it executes the code within ThreadFinished, for example: private void ThreadFinished() { .... //Thread has finished so show finish form and close frmFinished f = new frmFinished(); f.Show(); this.Close(); } Now this is where it goes wrong. Stepping through this code it show's the finished form as you can see it in the taskbar b ...Show All
XNA Rockstar Is possible to use .NET 2.0 in VS 2003?
Is possible to use .NET 2.0 in VS 2003 No, unless you want to create the files in 2003 then compile them by hand in outside the editor via the .net 2 SDK. yup..i agree with them, u cant do like this. because there are 2 difference version of framework. there got many new components in 2.0 that don have in vs2003 or 1.1 so vs2003 can't support it.... :) Hey jeusdi, I'm afraid Visual Studios won't allow you to do that. VS 2003 uses the .NET 1.1 framework while VS 2005 uses the .NET 2.0 framework. You can use .NET 1.1 components in .NET 2.0, but you cannot use .NET 2.0 components in an older environment. Hope this helps!. ...Show All
aragon127 Reading a binary file stored with c++ and MFC into c#.net
I have data I stored as binary files from old program. This was in c++ MFC. I now need to read these files into a new program written in c#.net. These files contain a mixture of data types, boolenan, int32, CStrings, CTime and various arrays. The bit I am having a problem with is the CArrays. These are of various types (ints, doubles, strings). The other data I have read as: BinaryReader binReader = new BinaryReader ( File .Open(FileName, FileMode .Open)); try { // If the file is not empty, // read the application settings. if (binReader.PeekChar() != -1) { FileVersion = binReader.ReadInt32(); sLowestWavelength = binReader.ReadString(); nNoRefPoints = binReader.ReadInt16(); RefAttenGood = binReader.ReadBoolean(); ...Show All
danni123 difference between out and ref keywords
plz does anyone can tell me difference between out and ref keywords the main difference is out parameters don't need to be initialised before the method is called and ref parameters do, so if you had the method: public void Add(out int result) { result = 10; } the following would be valid: int functionResult; Add(functionResult); Whereas if the result parameter was a ref, it wouldn't even compile as the variable isn't initialised before the method is called. Hi, in addition to Muhammad: out and ref parameters can be treated quite differently in cross process or cross app domain calls. out params need not to be marshalled to the called method, only when the method returns the out param is marshalled to its cal ...Show All
ILWerne Writing a 16-bit grayscale image
I have a byte array containing pixel values for a 16bpp grayscale image. I need a solution for converting said array to a bitmap image. So far I've come up with this: internal static Image imageFromArray(byte[] array) { const int WIDTH = 1472; int height = (array.Length) / WIDTH / 2; Bitmap bitmap = new Bitmap(1472, height, PixelFormat.Format16bppGrayScale); for (int x = 0; x < height; x++) for (int y = 0; y < WIDTH; y++) bitmap.SetPixel(x, y, (Color)array[(y * 1472 + x) * 2]); Image image = bitmap; return image; } But there is an error because I can't cast the byte as a color. So my question is, how do I actually translate my pixel data from the byte[] to the bitmap Is there a better way to do t ...Show All
Jack Wheeler Change CurrentUICulture
Hi pl, i have a project that works with numbers , it converts them from string to numbers,, so i have to trim the currency symbol, for example the $ symbol. but i got exceptions when the user regional configuration is set for example from europe or south america cause my function trim the $ symbol and the convert it to a number and with this configuration it crashes. so i need my application to only run with a determined Culture , i found some examples on the web but they didnt worked, maybe im doing something wrong, can some 1 explain me pls how can i force to use a pre-determined Culture in my app mig16 If your strings have a "$" currency symbol, even when a different culture is selected, t ...Show All
dlcollison How to know whether an Excel file is open and close it automatically?
In my application, I should write data to an Excel file. I can pause the application, and go to open the Excel file to see the data I received. However, when I start the application again with the Excel file open, there will be erros shown: "My application" has encountered a problem and needs to close. We are sorry for the inconvenience. It seems the application can not write data to an Excel file with the file is open...(no such problem with text file) Q1. How to check whether an Excel file is open or not Q2. How to close the Excel file automatically and then write data to the file again Thanks in advance! Oh, thanks, close to my problem // Get all instances of Notepad running on the local // ...Show All
VinceExtense How do you REMOVE or DELETE Items from Recent Projects list in VS2005 RC?
I have been testing VS2005 RC and as a result, I have built many applications. Most I am no longer interested in or use and would like to DELETE them from the RECENT Projects list, but I dont see how ! I have been achieving this by manualy deleting the project from IIS, but there's got to be a better way ! Any ideas cheers, yousaid My suggestion is to allow individual removal of projects from the MRU list. Why As I work on my main two or three projects, I may start a new "scratch" project or two to test some code. I don't want to inject this test code into my main project. But I don't want to lose the main projects off the MRU list either. So, let me clean up the list selectively please. ...Show All
DR_CHAOS Creating an array of bitArray
Hi, I want to create an array of BitArray(i.e. BitArray[]) and with each BitArray having a size of n. Is it possible Thanks Currently I'm using this. BitArray[] a = new BitArray[numVar]; for (int i = 0; i < numVar; i++) { a[ i ] = new BitArray(numProc); } Would there be a better way I meant can I skip the iterative step Not really. What's wrong with the way you're doing it now ...Show All
b2sing4u Fail to Load dll from C# when no VS2005 installed
Hi, I am running C# application with a MFC dll on VS2005. When I copy the .exe file and the dll to another computer I get the following errer (both installed with .NET 2.0): An unhandled exception of type 'System.IO.FileNotFoundException' occurred in FilesUpdateApplication.exe Additional information: Could not load file or assembly 'StrtData, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. where 'StrtData is my dll file. When I installed the VS2055 on the computer, it worked just fine. Are there any specific dll's that the 2005 adds is it something that it adds in the installation Please advice, Thanks Idit Hi, are both your exe and dll in ...Show All
Andrew Buyan Class Design
Hi all I am having one of those days where I really don't think my class design is up to standard so I thought I would ask your opinion. So far I have split my application into the following classes employee - CheckCredentials(username, password) - Update Name(first, second) stock - CheckItem(barcode) // Checks if the item is in the stock manifest - SellItem(barcode) // Removes stock item from inventory report - Generate() - View() - Save(path) database - Connect() - SelectQuery(query) - UpdateQuery(query) - Disconnect() - State { get } Now what is the best way to link the classes I could in every form create a new instance of employee, stock or report. This is floored though as I want the same database instance used ...Show All
aschaeffer How can I make a real clock face?
... Like in the tray when you double-click it, a window appears. I want to make the clock face in that window. How can I do that Hi, Here is an interesting article about it http://www.codeproject.com/cs/miscctrl/AnalogClockControl.asp Hope this helps ...Show All
