@manhng

Welcome to my blog!

VB To CSharp Converter

August 26, 2021 10:35

VB To CSharp Converter (edit)

  • Windows 10
  • .NET Framework 4.6
  • Visual Studio 2019
  • ASP.NET MVC 5 Web Application (VB.NET)
  • Code Converter (VB - C#) (Visual Studio Marketplace)
  • ASP.NET MVC Pattern ~ Model View Controller (MVC)
  • Design Principles (Architectural principles | Microsoft Docs)
    • Separation of concerns
    • Encapsulation
    • Dependency inversion
    • Explicit dependencies (Active Record Pattern)
    • Single responsibility: Object-Oriented design
    • Don't repeat yourself (DRY)
    • Persistence ignorance: Redis cache or Azure Cosmos DB and Plain Old CLR Objects (POCOs)
    • Bounded contexts: Domain-Driven Design

Windows 10 and .NET Framework

Mailbag: What version of the .NET Framework is included in what version of the OS? | Microsoft Docs

.NET Framework version history - Wikipedia (.NET Framework and Visual Studio)

Install the .NET Framework on Windows 10 | Microsoft Docs

.NET Framework & Windows OS versions | Microsoft Docs

Windows 10 (all editions) includes the .NET Framework 4.6 as an OS component, and it is installed by default. It also includes the .NET Framework 3.5 SP1 as an OS component that is not installed by default. The .NET Framework 3.5 SP1 can be added or removed via the Programs and Features control panel.

Windows 10 November 2015 Update (all editions) includes the .NET Framework 4.6.1 as an OS component, and it is installed by default. It also includes the .NET Framework 3.5 SP1 as an OS component that is not installed by default. The .NET Framework 3.5 SP1 can be added or removed via the Programs and Features control panel.

Windows 10 Anniversary Update (all editions) includes the .NET Framework 4.6.2 as an OS component, and it is installed by default. It also includes the .NET Framework 3.5 SP1 as an OS component that is not installed by default. The .NET Framework 3.5 SP1 can be added or removed via the Programs and Features control panel.

Windows 10 Creators Update (all editions) includes the .NET Framework 4.7 as an OS component, and it is installed by default. It also includes the .NET Framework 3.5 SP1 as an OS component that is not installed by default. The .NET Framework 3.5 SP1 can be added or removed via the Programs and Features control panel.

Windows 10 Fall 2017 Creators Update (all editions) includes the .NET Framework 4.7.1 as an OS component, and it is installed by default. It also includes the .NET Framework 3.5 SP1 as an OS component that is not installed by default. The .NET Framework 3.5 SP1 can be added or removed via the Programs and Features control panel.

Windows 10 April 2018 Update (all editions) includes the .NET Framework 4.7.2 as an OS component, and it is installed by default. It also includes the .NET Framework 3.5 SP1 as an OS component that is not installed by default. The .NET Framework 3.5 SP1 can be added or removed via the Programs and Features control panel.

SharpDevelop Team

Convert VB.NET to C# and vice versa with this roslyn based converter

Adds context menu items to convert projects/files between VB.NET and C#.

Code Converter (VB - C#) - Visual Studio Marketplace

Razor syntax with VB. Here's a couple of resources:

http://www.mikesdotnetting.com/Article/225/Migrating-Classic-ASP-To-ASP.NET-Razor-Web-Pages-Part-One--Razor-Syntax-And-Visual-Basic

http://www.asp.net/web-pages/overview/getting-started/introducing-razor-syntax-(vb)

ASP.NET MVC 5 and Visual Basic | The ASP.NET Forums

Works with: Visual Studio 2017, 2019, 2022

Code Converter C# to VB and VB to C# – Telerik

Data Mapper and Active Record Design Patterns in C#

Data Mapper and Active Record Design Patterns in C# – ScottLilly.com

using System.Data;
using System.Data.SqlClient;
 
namespace DesignPatternDemos.ActiveRecord
{
    public class Customer
    {
        private const string CONNECTION_STRING =
            "Data Source=(local);Initial Catalog=DesignPatterns;Integrated Security=True";
 
        public int ID { get; set; }
        public string Name { get; set; }
        public bool IsPremiumMember { get; set; }
 
        public Customer(int id, string name, bool isPremiumMember)
        {
            ID = id;
            Name = name;
            IsPremiumMember = isPremiumMember;
        }
 
        // This static method acts like an object factory for Customer objects,
        // reading the values from the database and creating the object.
        //
        // So, the code to get a customer from the database might be:
        //
        //    Customer.GetByID(123);
        //
        public static Customer GetByID(int id)
        {
            using(SqlConnection connection = new SqlConnection(CONNECTION_STRING))
            {
                connection.Open();
 
                using(SqlCommand command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.Text;
 
                    command.CommandText = "SELECT TOP 1 * FROM [Customer] WHERE [ID] = @ID";
                    command.Parameters.AddWithValue("@ID", id);
 
                    SqlDataReader reader = command.ExecuteReader();
 
                    // If the query returned a row, create the Customer object and return it.
                    if(reader.HasRows)
                    {
                        reader.Read();
 
                        string name = (string) reader["Name"];
                        bool isPremiumMember = (bool) reader["IsPremiumMember"];
 
                        return new Customer(id, name, isPremiumMember);
                    }
                }
            }
 
            return null;
        }
 
        public void Save()
        {
            // This method needs to handle INSERT (new Customer) and UPDATE (existing Customer).
            // Or, you would need to create two separate functions, and call them when appropriate.
 
            // This function would not need to receive a parameter, with the Customer object.
            // It's inside the Customer object, so all the property values are already available to it.
 
            // Pretend there is code here to do the insert and/or update to the database.
        }
 
        public void Delete()
        {
            using(SqlConnection connection = new SqlConnection(CONNECTION_STRING))
            {
                connection.Open();
 
                using(SqlCommand command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.Text;
 
                    command.CommandText = "DELETE FROM [Customer] WHERE [ID] = @ID";
                    // This method uses the ID value from this object's property.
                    // This function didn't need to receive that value from a parameter.
                    command.Parameters.AddWithValue("@ID", ID);
 
                    command.ExecuteNonQuery();
                }
            }
        }
    }
}

Java Design Patterns

Principles - Java Design Patterns (java-design-patterns.com)

Contents

Categories

Recent posts