Dim C As MyClass & Dim C As New MyClass?
May 17, 2011It's a simple concept, but one I've never been taught
View 1 RepliesIt's a simple concept, but one I've never been taught
View 1 RepliesI have a list of properties and values that i'd like to use to dynamically build an Expression(Of Func(Of MyClass,MyClass))
I can run through the list and create each Expression by itself, but the only way I know how to combine them would be to use Expression.And or Expression.AndAlso, but that returns a BinaryExpression rather than my original Expression(Of Func(Of MyClass,MyClass)).
In C# .NET 3.5, is there a way to instantiate an object given its string name? For example, suppose I have a DLL (e.g., MyClass.DLL) which contains type MyClass. Is possible to write something like... Object myClass = SomeMethodToInstantiate("MyClass"); // ? Is it possible to do this in VB .NET 3.5?
View 2 RepliesThe MyClass keyword behaves like an object variable referring to the current instance of a class as originally implemented. MyClass is similar to Me, but all method calls on it are treated as if the method were NotOverridable. I can see how that could kind of be useful, in some specific scenarios. What I can't think of is, how would you obtain the same behavior in C# - that is, to ensure that a call to a virtual method myMethod is actually invoked against myMethod in the current class, and not a derived myMethod (a.k.a in the IL, invoking call rather than callvirt)?
View 3 RepliesIn what scenarios would one use the MyBase and MyClass keywords in VB.NET?
View 5 Repliesi have a code like this
'bug_message is a public shared property
Public Shared Sub bug(ByVal bug_message As String)
msgbox(XX_format(MyClass.bug_message, bug_message))
End Sub
however i get this error: MyClass is valid only within an instance method. I do not wish to use the actual name of my class, and if i could i would prefer to keep the name of the argument as bug_message as well.
I'm using VS 2010 so I have auto-implemented properties.I have a class and I want to access the properties by a string.[code]But, I also want to be able to access the variables something like this way.[code]How can I setup MyClass to work both ways?
View 7 RepliesIs there a simple way to remove Objects from a List by using a specified value?I add 2 persons to a List, how can now I remove a person by a name without using any Loops? (if possible)
[Code]...
I am trying to use myclass.cs from aspx.vb but receive error "myclass not declared" when I give command:
Imports myclass
I'm getting a: mypage.aspx.vb(390,0): error BC30002:Type 'MyNamespace.MyClass' is not defined when I try to compile, run, etc. my website. What's really odd is that I don't have anything in my Error List before or after I do this. I wouldn't have an idea of what was wrong, except I have my compile verbosity turned way up. The line it's failing on looks like:
[Code]...
Traditionally, class/type name is literally spelled inside its definition.
Public Class MyCustomClass
Public child As MyCustomClass
Public Shared Function Clone(ByVal original As MyCustomClass) As MyCustomClass
End Class
This is not a problem most of the time; C-languages even use class name as constructor methods' name. But consider a generic declaration:
Public Class MyListOfIntegers
Inherits MyCustomList(Of Integer)
End Class
[code]....
This scenario has 2 issues. The first one is that constructors are not inherited, and you have to provide pass-through wrappers in every derived class, — this is quiet dumb, but tolerable. The second issue is more severe: derived class inherits CloneMe() method which returns MyCustomList(Of Integer) , not MyListOfIntegers ! Every returned value must be manually DirectCast 'ed for further use with methods that expect MyListOfIntegers . This issue, together with the first one, renders inheritance of generic class almost useless.
So I need a "MyClass" alternative for static type-binding inside type definition. In case of generic type that is referencing other compound types, task could be accomplished by adding second parameter to type section:
Public Class MyCustomList(Of T, TList)
...
Public Function CloneMe() As TList
[code]....
But since we must reference our own type, it would create an infinite recursive loop of additional typeparamlist arguments. How can this be resolved, aside of creating separate classes without generics?
I can't seem to find the correct words to search for an answer. I'm using VS 2010 so I have auto-implemented properties.I have a class and I want to access the properties by a string.
Public Class MyClass
Property Prop1 As String
Property Prop2 As String[code].....
But, I also want to be able to access the variables something like this way....
Dim MyVar = New MyClass
MyVar.Items("Prop1") = "Prop1 Value"
MyVar.Items("Prop2") = "Prop2 Vaule"
How can I setup MyClass to work both ways?
dim oXT As New Generic.SortedDictionary(Of String, MyClass)
[Code]...
If I do this: Dim w As MyClass = otherObject. where "otherObject" is another variable containing an instance of MyClass, I can be sure that w is a completely different variable? I mean, whatever changes I do to w, will NOT affect otherObject, right?
View 2 Replies