Link to home
Start Free TrialLog in
Avatar of juststeve
juststeve

asked on

Passing and using a param

Starting a transition from VB to C# and am confused by a code sample below - specifically the line:

 DateTime dateTime = (DateTime)obj;

When I use a C# to VB translator that line becomes:

      Dim dateTime As DateTime = CType(obj, DateTime)


which i get. Still...seems very strange to see the parens _leading an object. Perhaps a couple words of explaination would get my head the rest of the way around what's going on there.
class DateTimeRenderer : IObjectRenderer
    {
        public void RenderObject(object obj, System.IO.TextWriter writer) {
            DateTime dateTime = (DateTime)obj;
            writer.Write(dateTime.ToString("yyyy/MM/dd HH:mm:ss.fff"));
        }
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of juststeve
juststeve

ASKER

Putting the name 'Casting' to it - very helpful...thx
Not a problem, glad to help.  ;=)