Linked Questions
10 questions linked to/from downcast and upcast
2
votes
8
answers
2k
views
why this downcast fail in C#?
i have a base class and derived class like below
public class BaseClass
{
public int No { set; get; }
}
public class Derived : BaseClass
{
public string Name { set; get; }
}
when i create ...
2
votes
2
answers
3k
views
Is it really downcasting not possible? It is working fine for me
I know there are already some questions posted related to this same topic, but I have seen different answers so I am quite confused on which answer is correct.
On the below link, people mentioned ...
2
votes
6
answers
901
views
Writing Upcasting and Downcasting expressions in c#
I have been recently studying upcasting and downcasting in c#. I understand that upcasting refers to conversion from a derived class to a base class. However, when i see a practical example of ...
3
votes
3
answers
1k
views
C# - Inherited method passing self object
The real problem comes up with Reflection and assembly patching/hooking. I'll put a simple example to show up my question without being too hard to understand the main problem.
So let's imagine I ...
0
votes
3
answers
3k
views
Can not access derived class fields using base class
I am not able to access simple field from derived class so what
is use of polymorphism in case of fields. If I have to downcast to ResponseMBP to get the Name property then my client needs to know ...
1
vote
1
answer
2k
views
MVC Model Class Casting
I have an asp.net mvc application. I have two model class like this:
public class BaseViewModel
{
...
}
public class DerivedViewModel : BaseViewModel
{
...
}
I have a view and I want to use ...
3
votes
3
answers
2k
views
ASP MVC - Model is Null
I am trying to get an integer value from my controller to my view, and then adding that value as a Hidden Field to be used later in my JavaScript client-code.
I am getting an exception while trying ...
2
votes
2
answers
234
views
calling specific methods of generic types in ny equals() method
I am working on the equals() method for my sparse matrix class that I'm writing (part of a school project). I am constantly runnung into the issue that it won't let me use any methods or other ...
0
votes
1
answer
528
views
Can not cast from source type to destination type
I am writing a game in Unity, and I am trying to use polymorphism to access 2 subclasses but keep getting an error:
Can not cast from source type to destination type
I have a serialized list of ...
0
votes
1
answer
63
views
create a variable of derived class to refer an object of base class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication12
{
public class Foo
{
public virtual ...