M
M
mletov2018-03-04 11:15:11
C++ / C#
mletov, 2018-03-04 11:15:11

How can a variable of one type in C# be assigned to another if they are not in the same inheritance branch?

Please, prompt:
Here is in C# here such type XNamespace.
Inherits directly from System.Object.
At the same time, this form of writing is quite legitimate:

XNamespace ds = "http://www.w3.org/2000/09/xmldsig#";

How is this possible? After all, the string type is neither parent nor child of XNamespace, but one is cast to the other.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2018-03-04
@mletov

Because there is such an operator that constructs an XNamespace from a string.
https://msdn.microsoft.com/en-us/library/system.xm...

#
#, 2018-03-04
@mindtester

this means that there is either an overloaded assignment operator , but most likely just a type extension , for the necessary conversion

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question