Click here to Skip to main content
16,018,949 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Questions Pin
PIEBALDconsult8-Jul-14 9:08
mvePIEBALDconsult8-Jul-14 9:08 
AnswerRe: C# Questions PinPopular
Pete O'Hanlon8-Jul-14 9:19
mvePete O'Hanlon8-Jul-14 9:19 
GeneralRe: C# Questions Pin
Richard Andrew x648-Jul-14 11:00
professionalRichard Andrew x648-Jul-14 11:00 
GeneralRe: C# Questions Pin
Pete O'Hanlon8-Jul-14 11:16
mvePete O'Hanlon8-Jul-14 11:16 
GeneralRe: C# Questions Pin
shiftwik8-Jul-14 21:10
shiftwik8-Jul-14 21:10 
AnswerRe: C# Questions Pin
OriginalGriff8-Jul-14 9:32
mveOriginalGriff8-Jul-14 9:32 
GeneralRe: C# Questions Pin
shiftwik8-Jul-14 21:09
shiftwik8-Jul-14 21:09 
GeneralRe: C# Questions Pin
OriginalGriff8-Jul-14 21:21
mveOriginalGriff8-Jul-14 21:21 
Simply because C# doesn't try to "guess" what you wanted.
Think about it: I don't want the system creating a new instance every time I try to use an existing one, because it means a trip to the DB and back to create an item that I may not use again - and the "real" DB item then doesn't get updated.

I want the system to create an instance only when I specifically tell it to.
If the system created them for me, then
C#
MyClass[] data = MyClass[10];

Would create an array of references to MyClass instances and the instances to fill it with.
I may not want that: if MyClass always contains an enormous Bitmap (for example) that is a huge amount of time and memory being wasted, because I'm about to fill the array with the top ten instances from the DB when I call the method below it:
C#
MyClass[] data = MyClass[10];
DAL.GetImageData(data, 10, "SEARCH CONDITION");
But the system can't know that because it doesn't have any idea what the method does - it's in a separate DLL!

The new keyword allow you to specify exactly when you want an instance created (and reminds you that this could take some time and / or resources when it does it)
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

GeneralRe: C# Questions Pin
Erik Westermann11-Jul-14 3:48
professionalErik Westermann11-Jul-14 3:48 
GeneralRe: C# Questions Pin
OriginalGriff8-Jul-14 21:23
mveOriginalGriff8-Jul-14 21:23 
GeneralRe: C# Questions Pin
Richard Deeming9-Jul-14 1:48
mveRichard Deeming9-Jul-14 1:48 
GeneralRe: C# Questions Pin
OriginalGriff9-Jul-14 2:30
mveOriginalGriff9-Jul-14 2:30 
GeneralRe: C# Questions Pin
Nicholas Marty9-Jul-14 4:33
professionalNicholas Marty9-Jul-14 4:33 
GeneralRe: C# Questions Pin
Richard Deeming9-Jul-14 5:03
mveRichard Deeming9-Jul-14 5:03 
GeneralRe: C# Questions Pin
Nicholas Marty9-Jul-14 20:32
professionalNicholas Marty9-Jul-14 20:32 
GeneralRe: C# Questions Pin
Richard Deeming10-Jul-14 1:01
mveRichard Deeming10-Jul-14 1:01 
GeneralRe: C# Questions Pin
Nicholas Marty11-Jul-14 0:48
professionalNicholas Marty11-Jul-14 0:48 
AnswerRe: C# Questions Pin
V.9-Jul-14 1:40
professionalV.9-Jul-14 1:40 
GeneralHelp Pin
gsn19708-Jul-14 8:13
gsn19708-Jul-14 8:13 
GeneralRe: Help Pin
Richard MacCutchan8-Jul-14 8:23
mveRichard MacCutchan8-Jul-14 8:23 
GeneralRe: Help Pin
Pete O'Hanlon8-Jul-14 9:37
mvePete O'Hanlon8-Jul-14 9:37 
GeneralRe: Help Pin
gsn197015-Jul-14 21:18
gsn197015-Jul-14 21:18 
GeneralRe: Help Pin
Pete O'Hanlon15-Jul-14 21:44
mvePete O'Hanlon15-Jul-14 21:44 
GeneralRe: Help Pin
gsn197018-Jul-14 0:42
gsn197018-Jul-14 0:42 
Generalneed your help Pin
gsn197025-Sep-14 4:12
gsn197025-Sep-14 4:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.