Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
AnswerRe: Only numeric ( Back Space is working also ) Pin
Dave Kreskowiak6-Mar-19 2:23
mveDave Kreskowiak6-Mar-19 2:23 
GeneralRe: Only numeric ( Back Space is working also ) Pin
Bayram Demirci6-Mar-19 2:56
Bayram Demirci6-Mar-19 2:56 
GeneralRe: Only numeric ( Back Space is working also ) Pin
Dave Kreskowiak6-Mar-19 5:49
mveDave Kreskowiak6-Mar-19 5:49 
GeneralRe: Only numeric ( Back Space is working also ) Pin
BillWoodruff8-Mar-19 22:55
professionalBillWoodruff8-Mar-19 22:55 
AnswerRe: Only Numeric Textbox ( Back Space is working ) Pin
Gerry Schmitz6-Mar-19 4:30
mveGerry Schmitz6-Mar-19 4:30 
AnswerRe: Only Numeric Textbox ( Back Space is working ) Pin
qA-Cp24-Mar-19 23:27
qA-Cp24-Mar-19 23:27 
QuestionEfficient way of updating items Pin
Danpeking6-Mar-19 0:41
Danpeking6-Mar-19 0:41 
AnswerRe: Efficient way of updating items Pin
OriginalGriff6-Mar-19 1:01
mveOriginalGriff6-Mar-19 1:01 
You first line of code will not automatically "call the Dispose event" unless your Companies collection specifically does that when you overwrite an element - in which case there is probably a very, very good reason for it.
And your second code does not do the same thing at all - it overwrites parts of the class instance held by the collection which alters the instance throughout the app.
For example:
C#
class MyClass
   {
   public int Value {get; set;}
   public MyClass(int x) { Value = x;}
   }
MyClass[] data = new MyClass[2];
MyClass x = new MyClass(333);
MyClass y = new MyClass(666);
myClass z = new MyClass(999);
myClass[0] = x;
myClass[1] = y;
myClass[0] = z;
myClass[1].Value = 111;

Changing x.Value will not affect the value in MyClass[0] and vice versa, changing the value of y will affect the value of myClass[1] and vice versa. Changing myClass[0] or z will affect both because they are the same instance.

I think you need to think a bit more carefully before you continue, and find out why the collection is calling Dispose - it implies the Company has important other info which needs to be replaced and Disposed, which your second code example does not do.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

AnswerRe: Efficient way of updating items Pin
F-ES Sitecore6-Mar-19 2:35
professionalF-ES Sitecore6-Mar-19 2:35 
AnswerRe: Efficient way of updating items Pin
Gerry Schmitz6-Mar-19 4:24
mveGerry Schmitz6-Mar-19 4:24 
QuestionVS 2017 c# Getting Current Version number Pin
ormonds5-Mar-19 16:52
ormonds5-Mar-19 16:52 
AnswerRe: VS 2017 c# Getting Current Version number Pin
OriginalGriff5-Mar-19 20:04
mveOriginalGriff5-Mar-19 20:04 
GeneralRe: VS 2017 c# Getting Current Version number Pin
ormonds6-Mar-19 17:54
ormonds6-Mar-19 17:54 
GeneralRe: VS 2017 c# Getting Current Version number Pin
OriginalGriff6-Mar-19 22:11
mveOriginalGriff6-Mar-19 22:11 
GeneralRe: VS 2017 c# Getting Current Version number Pin
ormonds7-Mar-19 0:33
ormonds7-Mar-19 0:33 
QuestionBest Architecture dotnet app Pin
Member 132039775-Mar-19 5:38
Member 132039775-Mar-19 5:38 
AnswerRe: Best Architecture dotnet app Pin
Gerry Schmitz5-Mar-19 7:57
mveGerry Schmitz5-Mar-19 7:57 
RantRe: Best Architecture dotnet app Pin
Bohdan Stupak5-Mar-19 22:25
professionalBohdan Stupak5-Mar-19 22:25 
GeneralRe: Best Architecture dotnet app Pin
Member 132039775-Mar-19 23:42
Member 132039775-Mar-19 23:42 
GeneralRe: Best Architecture dotnet app Pin
Bohdan Stupak6-Mar-19 1:04
professionalBohdan Stupak6-Mar-19 1:04 
QuestionUsing the Black Box method in C# Pin
Brian_TheLion4-Mar-19 18:57
Brian_TheLion4-Mar-19 18:57 
AnswerRe: Using the Black Box method in C# Pin
OriginalGriff4-Mar-19 20:00
mveOriginalGriff4-Mar-19 20:00 
GeneralRe: Using the Black Box method in C# Pin
Brian_TheLion4-Mar-19 23:20
Brian_TheLion4-Mar-19 23:20 
GeneralRe: Using the Black Box method in C# Pin
OriginalGriff5-Mar-19 0:04
mveOriginalGriff5-Mar-19 0:04 
GeneralRe: Using the Black Box method in C# Pin
Brian_TheLion5-Mar-19 11:47
Brian_TheLion5-Mar-19 11:47 

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.