Hello Friends

I am developing an application in C# , basically it intercept all the event of Visual Source Safe. Earlier code was in VB.net but Now we are migrating to C#.
Now I am unable to find replacement of following funtion of VB.
---------------------------------------------------------------------------------
VB code Starts here:
---------------------------------------------------------------------------------

Function VSSHandler_BeforeCheckIn(ByVal Item bla bla bla)

shouldTakeVersion = False
For Each objVSSVersion In Item.Versions
            If shouldTakeVersion And Left(objVSSVersion.Label, 10) <> "Production" Or Left(objVSSVersion.Label, 10) = "production" Then
                intProdVersion = objVSSVersion.VersionNumber
                Exit For
            End If
            If Left(objVSSVersion.Label, 10) = "Production" Or Left(objVSSVersion.Label, 10) = "production" Then
                shouldTakeVersion = True
            End If
        Next objVSSVersion

---------------------------------------------------------------------------------
VB code Ends here:
---------------------------------------------------------------------------------

I will be glad if someone can explain this code and gives me difference of Item.Version and Item.Versions..

Waiting for prompt reply.

I will be glad if you explain this code and gives me difference of Item.Version and Item.Versions..

Item.Version represent single value where as Item.Versions is a collection (multiple values).

This is just a quick step through, it doesn't seem to be a very good method of going about whatever this is for. This method depends on some preexisting instances of objects and variables so I just translated it the best I could Its not guaranteed But im rusty on my VB. but it didn't look like it would have worked the way it was, but then again, it relies on preexisting objects so its kind of confusing.

//create method that accepts bbjVSSVersion Object Instance
private void VSSHandler_BeforeCheckIn(objVSSVersion Item)
{
//set a preexisting variable to false
shouldTakeVersion = False
//Create a for each loop to look through each item in a collection
foreach(objVSSVersion OBJVSS in Item.Versions)
{
//there seems to be unreachable code, because you set should takeversion to false, the use a condition to check if its true, and it never will be
check if shouldtakeversion is true and substring the text to find out if the first 10 characters are the word production
if(shouldTakeVersion && OBJVSS.Label.Substring(0,10) != "production") || (OBJVSS.Label.Substring(0,10) == "production")
{
   //note there is a capitlization difference in your strings, I left it the way it was
//now if any conditions were true
intProdVersion = OBJVSS.VersionNumber;
//if conditions met exit the loop
break;
}
//check if it starts with the string production and if it does set variable to true
            if (OBJVSS.Label.Substring(0, 10) == "Production") 
                        || (OBJVSS.Label.Substring(0, 10) == "production")
            {
                shouldTakeVersion = true;
            }
//end of loop
}
//end of function
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.