-2
literal.Text = (gridView.Controls[i] as CheckBox).Checked ? "True" : "False";

How to convert this line to VB.Net syntax, could someone please help me?

Mark Hall
  • 53,938
  • 9
  • 94
  • 111
maufonfa
  • 92
  • 8
  • 2
    duplicate of http://stackoverflow.com/questions/576431/is-there-a-conditional-ternary-operator-in-vb-net – hatchet - done with SOverflow Jan 19 '12 at 14:53
  • You'd best learn to program. In this case the following happens: An element from an array is casted to a checkbox, then the Checked property is converted to a String in a rather cumbersome way. – TJHeuvel Jan 19 '12 at 14:55
  • 1
    *Too localized*? This is an exact duplicate, not too localized. He's asking how to convert that in general, which would help other people in the future if it weren't a duplicate. – Devin Burke Jan 19 '12 at 14:57
  • How can this be duplicate? Read the question and then comment – maufonfa Jan 19 '12 at 15:30
  • I know how to program in VB.Net no in C# so please don't mess with people knowledge. u r no god TJHeuvel – maufonfa Jan 19 '12 at 15:31

4 Answers4

1
 literal.Text = If(TryCast(gridView.Controls(i), CheckBox).Checked, "True", "False")

You can always use this nice online converter

Emmanuel N
  • 7,350
  • 2
  • 26
  • 36
  • +1 because it’s the direct translation but using `TryCast` here (and `as` in C#) is a bit weird since this could result in a `NullReferenceException`. – Konrad Rudolph Jan 19 '12 at 14:55
0

Cheat. Use a code converter. There are free ones online. Learn from what you get for results.

http://converter.telerik.com/

produces

literal.Text = If(TryCast(gridView.Controls(i), CheckBox).Checked, "True", "False")
David
  • 72,686
  • 18
  • 132
  • 173
0

there are online converters you can use to get pretty close for this stuff

http://www.developerfusion.com/tools/convert/csharp-to-vb/1

literal.Text = If(TryCast(gridView.Controls(i), CheckBox).Checked, "True", "False")
Brian
  • 2,229
  • 17
  • 24
0
literal.Text = If(TryCast(gridView.Controls(i), CheckBox).Checked, "True", "False")
shenhengbin
  • 4,236
  • 1
  • 24
  • 33