1 Replies - 1451 Views - Last Post: 03 December 2009 - 09:20 PM Rate Topic: -----

#1 Qrueger  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 19-November 09

Conversion VB.net to C# code

Post icon  Posted 03 December 2009 - 08:42 PM

hi guys,

I need opinion in my code,
usually I code in VB.net using with to shorting the code writing.
for example :
with DsCostumer.Tables[0].Rows[0]
	   test = .ItemArray[0]
end with

I tried to convert to C# code

DataRow  dat  = DsCostumer.Tables[0].Rows[0];

test = dat.ItemArray[i].ToString();

is this safe?, is this the way "With" replace in C#...

Thx for your help.

Is This A Good Question/Topic? 0
  • +

Replies To: Conversion VB.net to C# code

#2 SixOfEleven  Icon User is offline

  • Against the Grain
  • member icon

Reputation: 976
  • View blog
  • Posts: 6,430
  • Joined: 18-October 08

Re: Conversion VB.net to C# code

Posted 03 December 2009 - 09:20 PM

What you did would work if the type you are using is a class or other reference types. If you were using a struct however that wouldn't work. The reason why is that structs are value types. When you create a new struct and assign the values of an old struct to it you are actually making a copy of the old struct.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1