有没有办法从特定的命名空间中获取对象?或许与System.Reflections?我希望将所有对象从ITestType命名空间中的类型Test.TestTypes作为对象获取,以便我有一个实例列表,TestType1, TestType2, TestType3依此类推.有人能帮我吗?我不知道在哪里搜索.
我需要以编程方式获取List给定命名空间中的所有类.我怎样才能在C#中实现这个(反射?)?
我们有一个巨大的ASP.NET MVC 3应用程序.我们需要计算我们在课程中有多少公共方法currentClass is System.Web.Mvc.Controller.
任何符合此条件的类都将具有"AwesomeProduct.Web"的基本命名空间,但除了这些类可能属于哪个命名空间或者有多少深度级别之外,无法保证.
想出这个的最佳方法是什么?
是否有函数或使用反射方法来获取所有系统类型.
像那些: - System.Int64
System.Byte[]
System.Boolean
System.String
System.Decimal
System.Double
...
我们有一个旧的enum存储一些数据类型.我们需要将它们转换为.net types.
如何获取特定类型中使用的所有类型?
类“MyClass”的示例:
[MyAttribute(new OtherType(TestEnum.EnumValue1))]
public class MyClass:MyOtherClass
{
public Type MyType { get; set; }
public string MyString { get; set; }
private DateTime MyDateTime;
[OtherAttribute()]
public int MyMethod(double doubleNumber, float floatNumber)
{
justMyClass myJustClass = new justMyClass();
return (int)doubleNumber / (int)floatNumber + myJustClass.Count();
}
}
Run Code Online (Sandbox Code Playgroud)
我想获取类型:MyAttribute、OtherType、TestEnum、MyClass、MyOtherClass、Type、string、DateTime、OtherAttribute、int、double、float 和 justMyClass。
有什么办法可以做到吗?
我有一个函数接收类型并返回true或false.我需要找出某个命名空间中的所有类型,该函数将为它们返回true.谢谢.
有没有办法打印 C# 类库或命名空间中的所有枚举?我希望名称与其值一起打印。
例如,如果我有如下命名空间:
namespace MyCompany.SystemLib
{
public enum ItemStatus
{
None = 0,
Active = 1,
Inactive = 2
}
public enum MyEnum
{
EnumVal1 = 1,
EnumVal2 = 2,
EnumVal3 = 3,
}
}
Run Code Online (Sandbox Code Playgroud)
我想将它们按如下分隔打印(到文本文件) 为清晰起见,此处给出的项目符号在输出中不需要。
ItemStatus,None=0,Active=1,Inactive=1MyEnum,EnumVal1=1,EnumVal2=2,EnumVal3我不知道从哪里开始。任何帮助表示赞赏。
c# ×8
reflection ×6
.net ×4
namespaces ×2
appdomain ×1
asp.net ×1
asp.net-mvc ×1
process ×1
types ×1