Can I return class object from function in c# as a return value instead return string or int or ..etc
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
I'm assuming that you want to return a instance of a class from the function, then the answer is yes. An instance of a class is nothing more than an object like basically everything else in .NET.
Example:
I read your question as if a method can return a class. I would, presently, dare say No. Presently is 2018-04-05
Below I am using
System.Class
, a class most famous forSystem.Class.WriteLine
.One can not declare
to be able to
Someone Please prove me Wrong!
I would really love the functionality as it would help med mock a static.
A class object in C# is a Type. So you can definitely return it from a function: