TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
angwin
NA
4
0
Boxing Mystery in Overloaded and Overrided Method
Oct 9 2007 10:13 AM
Hello!
I have a class with two overloaded methods
int Foo(int i) { Foo(i); }
int Foo(int? i) { }
First method call leads to StackOverflowException. It is OK.
Change the code so that the base class contains virtual method "int Foo(int i)" and inhereted class declares
override
int Foo(int i) { Foo(i); }
int Foo(int? i) { }
After calling the first method, a mystery occurs - the value-type argument "i" is boxed and the second method is called instead of repeating the first one. Why? Articel with complete source code and its IL-code is here:
http://dotnet-enthusiast.blogspot.com/2007/09/boxing-mystery-in-overloaded-and.html
Reply
Answers (
2
)
IsNumeric
NP51 Carriage return \r in a program