Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Translating from VB to C# - Date

Status
Not open for further replies.

PIAS

Programmer
Nov 2, 2005
38
0
0
SI
Can someone tell me how goes this VB function in C#;

Weekday(dateYX,Microsoft.VisualBasic.FirstDayOfWeek.Monday)

and this

WeekdayName(dayX,False,Microsoft.VisualBasic.FirstDayOfWeek.Monday)

Thanks

PIAS
 
You can get the Day of the Week from

Code:
DateTime dt = DateTime.Today;
Convert.ToInt32(dt.DayOfWeek); // will give you the #
dt.DayOfWeek; // Will give you the Day

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
ok, thanks for that

Now i want to know what comes here;

VB = UBound <=> in C# = ?
 
thanks, but i still have a problem i don't know how to change it:

pozicije it's an array so how goes this code in C#;

CInt(pozicije(i))
 
This will do the type conversion
(int)pozicije

if pozicije is an array of integers then you shouldn't have to do the conversion

pozicije should suffice
I have not tested these lines.
 
It doesn't work.
maybe becaus it is in for loop;

Int32 oglas;
SqlCommand oCmd;
for (i=0; i<=(pozicije.Length); i++)
{
oglas = (int)pozicije; // oglas = CInt(pozicije(i))
oCmd.Parameters["@advId"].Value = oglas;
oCmd.Parameters["@pozicija"].Value = i;
oCmd.ExecuteNonQuery();
}

this code give's me this error;
Error 1 Cannot apply indexing with [] to an expression of type 'System.Array'
 
Maybe this working example will help

int[] pozicije = new int[5];
pozicije[0] = 123;
pozicije[1] = 321;
pozicije[2] = 12345;
pozicije[3] = 54321;
pozicije[4] = 99999;
for (int i=0; i<=(pozicije.Length -1); i++)
{
Console.WriteLine(pozicije);

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top