2.0 From VB to C#-VBForums
Results 1 to 2 of 2

Thread: From VB to C#

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2006
    Posts
    694

    From VB to C#

    how can I add module in C#.net so that i can declare my code just like in VB like these;

    Code:
    Public Sub ShowAllRecords()
    
    End Sub
    Code:
    Public Function GetCustomerName(ByVal CustomerID as Integer) As String
    
    End Function

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    86,138

    Re: From VB to C#

    There's no such thing as a module in C#. In C# you just have classes. In VB, a module member behaves like a class member that is Shared and the C# equivalent of Shared is 'static'. In C# you can declare the class itself static as well as the members, which means that the class cannot be instantiated and every member must be static, just like a VB module. In fact, once compiled, VB modules are implemented as static classes, which is why they don't break the OOP model.

    In VB, while modules do not require you to qualify the method, classes do. Classes are the same in C#.

    That said, judging by the names of those methods, they don't belong in a module or static class anyway.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.