powered by UserVoice

Code Converter Forum

Welcome to our official feedback forum for the code converter. If you spot problems with the converter, just leave a note here. **Please make sure you include a code sample***

  1. 3 votes

    BitWise operations

    public bool IsInRole(Role role) {
    Role userRole = (Role)this.Role;
    return ((userRole & role) == role);
    }

    [Flags]
    public enum Role {
    Student = 1, // 0001
    Employer = 2, // 0010
    Staff = 4, // 0100
    Admin = 8 // 1000
    }

  2. 1 vote

    Comparing potentially null variables

    string x = null;
    if(string.Empty == x)
    {
    System.Console.WriteLine("Shouldn't get here");
    }

    On conversion, the if statement uses = (If String.Empty = x) which will evaluate to true when x is nothing, but will not evaluate to true when x is null in C#.

  3. 1 vote

    problem with unary minus

    digit = int.Parse(number.Substring(i-1, 1));
    //ha em, your parser has a bug in unary expressions
    i switched the expression with (i+(–1))
    now it works

  4. 3 votes

    C# to Python huge error.

    From
    public partial class AllDepViewFieldCollection : RowDataAdapterCollection<AllDepViewField> converts to
    class AllDepViewFieldCollection(RowDataAdapterCollection).

    Where is generic type parameter?!!

  5. 1 vote

    Convert to VB.net

    <script language="javascript">
    function openPopup(strOpen)
    {
    open(strOpen, "Info",
    "status=1, width=300, height=200, top=100, left=300");
    }
    </script>

    This won't convert to vb.net

  6. 3 votes

    Braces

    A c# construct such as this:

    MyObject i;
    {
    i = new MyObject();
    }
    i.Run()

    Is converted to this:

    Dim i As MyObject
    If True Then
    i = New MyObject()
    End If
    i.Run()

    This produces a compiler warning, saying that i may not be initialized. A better conversion would be… more

  7. 1 vote

    Function declaration doesn't convert

    The following returns an error:
    "-- line 1 col 1: EOF expected" - Why would an EOF be expected at the beginning of the code to be translated??? Here is the code:
    Function xmlAddElement(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs, ByVal strID As String, ByVal strErrType As String) As… more

    Hey - try adding an End Function to the code - that should do the trick.

  8. 1 vote

    return objDataAccess.GetDataSet.Tables(0);

    return objDataAccess.GetDataSet.Tables(0);

  9. 3 votes

    i++; fails

    When converting the following from C# to VB.NET it fails to convert correctly.
    int i=5;
    int j=i++;
    //i=6 and j=5
    It sets Dim j = System.Math.Max(System.Threading.Interlocked.Increment(i),i-1)

    Not possible for i-1 to be greater than i+1

  10. 1 vote

    when converting string functions to vb it suggests to use string.* wich do not exists

    When converting the followong vb code to c# it suggests to use strings.mid() function in c# wich appears not to exists.

    Private Sub stringmid(ByVal str As String)
    Dim mystr As String
    mystr = Mid(str, 2)
    End Sub

    converts to

    private void stringmid(string str)
    {
    string mystr = null;
    mystr =… more

  11. 1 vote

    Implementing an Interface

    C# code to implement an interface:
    using System.ServiceModel;

    [CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
    internal class Callback : MyInterface

    Did not convert properly to VB.NET. The conversion had "Inherits MyInterface". It should've had "Implements MyInterface"

  12. 3 votes

    Convert this to vb

    CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
    {
    configSetter(ConfigurationManager.AppSettings[configName]);
    });

  13. 3 votes
  14. 1 vote

    I have a problem converting this code:

    public static readonly DependencyProperty ProgressProperty = DependencyProperty.RegisterAttached("Progress", typeof(double), typeof(ViewportAnimation), new PropertyMetadata(0.0, new PropertyChangedCallback(delegate(DependencyObject o, DependencyPropertyChangedEventArgs e) { ((ViewportAnimation)o).ProgressChanged(e); }))); VB.Net Converter gives me this:

    Public Shared ReadOnly ProgressProperty As DependencyProperty = DependencyProperty.RegisterAttached("Progress", GetType(Double), GetType(ViewportAnimation), New PropertyMetadata(0.0, New PropertyChangedCallback(Function(o As DependencyObject, e As DependencyPropertyChangedEventArgs) Do
    DirectCast(o, ViewportAnimation).ProgressChanged(e)
    End Function)))

    There seems… more

  15. 2 votes

    Dim b(b1.Length + b2.Length - 3) As Byte

    VB
    Dim b(b1.Length + b2.Length - 3) As Byte

    Converted C#
    byte[] b = new byte[b1.Length + b2.Length - 2];

    Why is it changing my math?
    I've been using this converter to teach myself C#. Great tool.

  16. 1 vote

    LINQ VB.Net -> C# (where clause)

    In this case, the converter doesn't work
    p.s. this syntaxe is valid in VB.Net

    From a In ListOfA
    Select a
    Where a Is A

    If we change the Where clause position, just like we do in C# in fact, it works :

    From a In ListOfA
    Where a Is A … more

  17. 1 vote

    CS -> VB lamba quirk

    C# implementation:

    Array.ForEach(
    Enum.GetNames(typeof(LightStyle)),
    s => m_lightstyle.Items.Add(new ListItem(s))
    );

    Due to VB inline functions requiring a return value, here is probably a better interpretation.

    VB Implementation:
    For Each s As String In [Enum].GetNames(GetType(LightStyle))
    Me._lightStyle.Items.Add(New ListItem(s))
    Next

  18. 1 vote

    Cannont convert Nullable property using ?

    When trying to convert from VB.Net to C# (or vice versa), if you have a nullable property that is created using the ? and not Nullable<> the post back on your page is not ready correctly.

    Public Property CurrentDate As DateTime?

    I should be able to pass that and get

    more

  19. 1 vote

    Pointers don't get converted properly

    This line of code:

    int* a = &b;

    gets converted into this:

    Dim a As Pointer(Of Integer) = AddressOfb

    As you can see, there is a space missing between AddressOf and b.

  20. 1 vote

    intptr == int after conversion from vb.net

    It's not possible in c# to confront an int pointer with an integer type

powered by UserVoice