473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Downcasting

Me
From C# Language Specification, 7.6.6 Cast expressions:
--------------------------------------------------------------------
A cast-expression of the form (T)E, where T is a type and E is a
unary-expression, performs an explicit conversion (Section 6.2) of the value
of E to type T. If no explicit conversion exists from the type of E to T, a
compile-time error occurs.
--------------------------------------------------------------------
Object E;
....
Foo F = (Foo)E;

There is no explicit conversion from Object to Foo, but the compiler can't
throw an error - whether the conversion will work isn't known until runtime.
Nov 16 '05 #1
1 2867
And?

Telmo Sampaio
MCT

"Me" <Me@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
From C# Language Specification, 7.6.6 Cast expressions:
--------------------------------------------------------------------
A cast-expression of the form (T)E, where T is a type and E is a
unary-expression, performs an explicit conversion (Section 6.2) of the
value
of E to type T. If no explicit conversion exists from the type of E to T,
a
compile-time error occurs.
--------------------------------------------------------------------
Object E;
...
Foo F = (Foo)E;

There is no explicit conversion from Object to Foo, but the compiler can't
throw an error - whether the conversion will work isn't known until
runtime.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Stuart Golodetz | last post by:
Hi, I've got a minor casting issue which I need to check about (marked // <--). I was trying to do a static_cast on it (which didn't work, though I'm not sure why this should be the case?) I...
9
by: Simon Elliott | last post by:
If I have a base class and several possible derived classes, and I have a pointer to the base class, what's the best way of determining whether the pointer is pointing to a base class or to a...
2
by: Michael | last post by:
Ok Guys, on the same thread I'm writing a Game engine, which performs collision detection. I want to sepate the collision boundings libaray from the main game engine and load it as a library....
6
by: Rein Petersen | last post by:
Hi Folks, I've accepted that one cannot downcast between types, however I can't find a way to achieve //... class Employee { public string name;
6
by: Fernando Rodríguez | last post by:
Hi, I have a class called UrlFetcher and keep several instances inside an ArrayList. This class has a fecth() method. When I iterate through the list calling the fetch() method, I have to...
4
by: Joe Doyle | last post by:
I'm trying to do this- .... void method1(System.Array arr) { // happen to know all elements in arr are int's // this line throws an InvalidCastException int intArr = (int) arr; }
3
by: Joe | last post by:
I know that I can upcast and /downcast in C#. Can it be done in VB.NET? I haven't seen any documentation on it. TIA, -- Joe VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA...
5
by: Ryan van Roode | last post by:
Hello, An API function gives me an object of class 'Blah'. I have subclassed 'Blah' and added a few methods: class EnhancedBlah extends Blah { function enhancement1() {} function...
9
snowfall
by: snowfall | last post by:
What is downcasting and how to implement it?? Am not getting any tutorial on this... pls help...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.