The code has no mistake. The as operator in C# doesnt return any error while
typecasting an object eventhough that is an extensionelement or not. You
should check the same in VB before type casting. In C#, the below code is also
correct :
foreach (Object o in entry.ExtensionElements )
{
if(o is ExtendedProperty)
{
ExtendedProperty p = (ExtendedProperty)o;
Tracing.TraceMsg("Found one extended property");
Assert.AreEqual(p.Name, "http://frank.schemas/2005#prop", "Expected the
same entry");
Assert.AreEqual(p.Value, "Mantek", "Expected the same entry");
prop = p;
}
}
Cheers
Kulvinder Singh
----- Original Message ----
From: Steve Hueners <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, February 6, 2008 6:52:35 PM
Subject: Reading an ExtendedProperty
A previous message asking about reading contents of ExtendedProperty pointed to
the unit test code in caltest.cs:
foreach (Object o in entry.ExtensionElements )
{
ExtendedProperty p = o as ExtendedProperty;
if (p != null)
{
Tracing.TraceMsg("Found one extended property");
Assert.AreEqual(p.Name,
"http://frank.schemas/2005#prop", "Expected the same entry");
Assert.AreEqual(p.Value, "Mantek", "Expected the
same entry");
prop = p;
}
}
I'm attempting to translate that to VB which comes back from my converter as:
For Each o As Object In entry.ExtensionElements
Dim p As ExtendedProperty = o
If Not (p Is Nothing) Then
Console.WriteLine(p.Value)
End If
Next o
But I get an exception at Dim p As ExtendedProperty = o . Is the same exception
being thrown in the unit test code but handled by an exception handler? Or is
it due some more nuanced difference between C# and VB?
thx
--steve...
System.InvalidCastException was unhandled
Message="Unable to cast object of type 'Google.GData.Extensions.Comments' to
type 'Google.GData.Extensions.ExtendedProperty'."
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---