new

Can I alter how types are resolved and instantiated in .NET?

In some languages you can override the "new" keyword to control how types are instantiated. You can't do this directly in .NET. However, I was wondering if there is a way to, say, handle a "Type not found" exception and manually resolve a type before whoever "new"ed up that type blows up? I'm using a serializer that reads in an xml-ba...

Is it useful to test the return of "new" in C++?

I usually never see test for new in C++ and I was wondering why. Foo *f = new Foo; // f is assumed as allocated, why usually, nobody test the return of new? ...

C# Using new[]

I have a question about using new[]. Imagine this: Object.SomeProperty = new[] {"string1", "string2"}; Where SomeProperty expects an array of strings. I know this code snippet will work. But i want to know what it does under the hood. Does new[] makes an instance of the class object and in SomeProperty it converts it automatically t...

What is a good GUI programming language for an experienced PHP developer?

I have been working with PHP for a while now and would like to learn some Windows desktop-based GUI applications. Something similar to C# or Visual Basic would be nice, however I would like to learn a language that is open, similar to PHP. Please do not suggest anything that requires an expensive compiler or one that does not allow yo...

What are uses of the C++ construct "placement new"?

I just learned about the C++ construct called "placement new". It allows you to exactly control where a pointer points to in memory. It looks like this: #include <new> // Must #include this to use "placement new" #include "Fred.h" // Declaration of class Fred void someCode() { char memory[sizeof(Fred)]; void* pla...

Dynamic Memory Allocation Failure Recovery

I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is not an option, and...

Checking C# new() initialisation for null?

I've found this piece of code on Koders: private ServiceProvider SiteServiceProvider { get { if (serviceProvider == null) { serviceProvider = new ServiceProvider(site as VSOLE.IServiceProvider); Debug.Assert(serviceProvider != null, "Unable to get ServiceProvider from site object."); ...

About constructors/destructors and new/delete operators in C++ for custom objects.

Suppose I have a Linked List I created myself. It has its own destructor, which frees the memory. This Linked List does not overload new or delete. Now, I'm trying to create an array of said linked lists (open hashing, if I understand correctly). Then I allocate the necessary memory inside the constructor of this open hashing class. The...

Add New Column in Infragistics Wingrid

I am using Infragistics wingrid in my application. I have assigned a datasource to my wingrid.Now i want to add a new column at a specific location. Can any one plz tell me how can this be performed. Regards, Savan ...

If I wanted to learn how to create web apps, what route would you all recommend?

Would you recommend: Taking an online course? If so, any recs? Reading books? If so, again any recs? Anything else? I'm 31 years old and have a great career so going back to school full-time isn't an option...but I would love to start learning how to program. ...

Is this dynamic memory allocation?

Simple question: do I have to 'delete' or 'delete []' c? Does the language matter? char c[] = "hello" ...

Array of structs and new / delete

I have a struct like this: class Items { private: struct item { unsigned int a, b, c; }; item* items[MAX_ITEMS]; } Say I wanted to 'delete' an item, like so: items[5] = NULL; And I created a new item on that same spot later: items[5] = new item; Would I still need to call delete[] to clean this up? Or won't this be needed...

Use new keyword if hiding was intended

I have the following snippet of code that's generating the "Use new keyword if hiding was intended" warning in VS2008: public double Foo(double param) { return base.Foo(param); } The Foo() function in the base class is protected and I want to expose it to a unit test by putting it in wrapper class solely for the purpose of unit tes...

VB.NET Dim vs. New

What are the differences between the following constructs? Why prefer one over the other? Dim byteArray(20) as Byte and Dim byteArray() as Byte = new Byte(20) {} Edit - Corrected the ReDim. Should be a Dim. ...

How do you start learning a new programming language?

A few days ago I came over this question: Did you ever switch from one programming language to another? and it seems, that almost everyone had this problem more than just once. What is your starting point for learning a new, similar (i.e. C to C++) or completely different (i.e. Perl to JAVA) new programming language? Do you use...

new on stack instead of heap (like alloca vs malloc)

Is there a way to use the new keyword to allocate on the stack (ala alloca) instead of heap (malloc) ? I know I could hack up my own but I'd rather not ...

What is Difference in assign an event...the correct method?

Hi Can you tell me what the difference is between these methods of attaching an event handler? //Method 1 this.button4.Click += new RoutedEventHandler(button4_Click); //Method 2 this.button4.Click += button4_Click; ... void button4_Click(object sender, RoutedEventArgs e) { } ...

Basic array initialization and sorting question.

Hi this is a rather basic java question I have an array containing String that i want to sort using java.util.Arrays.sort when i write String[] myArray = {"A","B","C"}; java.util.Arrays.sort(myArray); it gets sorted correctly however when i have String[] myArray = new String[10]; myArray[0] = "A"; myArray[1] = "B"; myArray[2] = "...

Is there any guarantee of alignment of address return by C++'s new operation?

Hi, Most of experienced programmer knows data alignment is important for program's performance. I have seen some programmer wrote program that allocate bigger size of buffer than they need, and use the aligned pointer as begin. I am wondering should I do that in my program, I have no idea is there any guarantee of alignment of address r...

Will new return NULL in any case?

I know that according to C++ standard in case the new fails to allocate memory it is supposed to throw std::bad_alloc exception. But I have heard that some compilers such as VC6 (or CRT implementation?) do not adhere to it. Is this true ? I am asking this because checking for NULL after each and every new statement makes code look very u...