HOW TO make VB to C# or C# to VB conversion code

With this HOW TO I would like to put together tips to make the code conversion VB to C# or C# to VB.

Asc Convert.ToInt32();
Chr Convert.ToChar();
Len String.Length();
Mid String.Substring();
ChrW(65) System.Convert.ToChar(65).ToString();

This post will be updated continuously by inserting each time new information.

Any suggestion is welcome.

Did my HOW TO help you? Leave a reply.

HOW TO add weeks to Date or DateTime

The Date and DateTime structures have the following methods:
AddYears(), AddMonths(), AddDays() but NOT AddWeeks() so you could use AddDays() to add the number of days of the week for each week or simply Add() to add TimeSpan, these aren’t professional solutions.

Use AddWeeks() method of Calendar class:

Imports System.Globalization

Dim cal As New Calendar

Dim newDate as Date = cal.AddWeeks(myDateTime, 1).Date
Dim newDateTime as DateTime = cal.AddWeeks(myDateTime, 1)

Also, you can use specific calendar changing Calendar class with others: GregorianCalendar, JapaneseCalendar, etc.
To read the complete list System.Globalization Namespace

Did my HOW TO help you? Leave a reply.