question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vb.net -> C#: Replace Visual Basic library calls with equivalent things from the .NET framework

See original GitHub issue

instead of using: !Information.IsDBNull

it should use !DBNull.Value.Equals

EDIT: See https://github.com/icsharpcode/CodeConverter/issues/174#issuecomment-461091117 for fuller listing

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
tverweijcommented, Sep 3, 2019

@GrahamTheCoder “Another good example in #345

Be carefull with this call.

See the following VB code

Public x As String = Nothing
Public y as String = IIf(x is Nothing, "123", q)

Public Function q()
  x = "ABC"
  exit x
End Function

The first line sets x to Nothing (null) The second line checks is x is nothing, then executes function q, and then returns “123”. If the first condition was also a function this would have been executed first.

If I replace the IIf with an If (so 1 I) then code runs as: The first line sets x to Nothing (null) The second line checks if x is nothing, so it returns “123” - q is NOT executed.

So iif(x Is Nothing, 1, x.length) will cause a runtime error While if(x Is Nothing, 1, x.length) will not

1reaction
GrahamTheCodercommented, Jan 10, 2019

Request to substitute Vb, Cr and VbCrlf with their string equivalent: https://github.com/icsharpcode/CodeConverter/issues/228

Read more comments on GitHub >

github_iconTop Results From Across the Web

VB to C# Functions
VisualBasic assembly, so you can use them directly. However, most of them have C# equivalents, or non language specific equivalents in core .NET...
Read more >
Tutorial: Create a .NET class library using Visual Studio
In this tutorial, you create a simple class library that contains a single string-handling method. A class library defines types and methods ...
Read more >
Breaking changes - .NET Framework to .NET Core
The most important breaking changes are added here as we become aware of them. Core .NET libraries. Change in default value of UseShellExecute ......
Read more >
String.Replace Method (System)
Returns a new string in which all occurrences of a specified Unicode character or String in the current string are replaced with another...
Read more >
Support Class (Microsoft.VisualBasic.Compatibility.VB6)
Some functions replace Visual Basic 6.0 functions that are no longer supported in Visual Basic; others compensate for differences in the object models....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found