Monday, July 11, 2022

MyClass keyword understanding

MyClass keyword understanding

    Must Read

  1. What .NET Developers Must Know about C++ Classes
  2. C++ does things differently than C# or Visual Basic, especially when it comes to class construction. Take this tour to learn about the differences.

  3. Chapter 4. Classes and Objects
  4. Chapter 3 discussed the myriad primitive types built into the C# language, such as int, long, and char. The heart and soul of C#, however, is the ability to create new, complex, programmer-defined types that map cleanly to the objects that make up the problem you are trying to solve.

    More Details

  5. MyClass equivalent in C#
  6. In looking at this question, commenter @Jon Egerton mentioned that MyClass was a keyword in VB.Net. Having never used it, I went and found the documentation on it:

    The 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 behaviour 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)?

  7. Me, My, MyBase, and MyClass in Visual Basic
  8. Me, My, MyBase, and MyClass in Visual Basic have similar names, but different purposes. This topic describes each of these entities in order to distinguish them.

  9. Comparison of C Sharp and Visual Basic .NET
  10. C# and Visual Basic .NET are the two primary languages used to program on the .NET Framework.

  11. C# equivalent of the vb isNothing
  12. VB.Net IsNothing Function returns a Boolean value indicating whether an expression has no object assigned to it. There is no direct, 100% equivalent of the Vb.Net function IsNothing, but the test against null accomplishes the same thing.

    IsNothing is intended to work on reference types. It returns True if the expression represents an object variable that currently has no object assigned to it; otherwise, it returns False.

    The null keyword is specific design feature in the C# language. It is a literal that represents a null reference, one that does not refer to any object. null is the default value of reference-type variables

  13. What is the C# equivalent to VB's Handles?
  14. I assume you mean for handling an event here. There are other Handles such as when discussing Windows API … Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub

    What is the C# equivalent to VB's friend?

    Assembly level class member visibility in C# is ‘internal' I believe.

  15. What is the C# equivalent to the VB Left function and right function?
  16. The Right function doesn’t exist in C#. However, you can create one, as well as a Left and a mid and make them work just like they do in VB.

    What you need to use is the SubString command and counters that dictate where to start and stop in a string of text. just remember to trap for errors such as the user sending values that would exceed the length of the string or trying to use negative numbers. Remember, Users are stupid.

  17. What is the C# equivalent to VB's InStr?
  18. You can use

    1. IndexOf(int, string, string) … This returns the offset of the first match after the integer value.
    2. IndexOf(string,string) … This returns the offset of the string.
    3. LastIndexOf(string,string) … This returns the last offset of your search value.
    All these methods have several overloads…. Refer to the manual for more help.

  19. What is the C# equivalent of with in VB.NET?
  20. Q:What is the C# equivalent of with in VB Dot thing

    A: Hmmm…….. I will assume the correct question is:

    What is the C# equivalent of “With” in VB dot thing?

  21. What is the new keyword for in this C# code?
  22. This is an Anonymous Type. Well, not truly anonymous, the compiler will assign an auto generated name for such class. It's said to be anonymous because the developer does not have to bother to give such class a name because the compiler will automatically create a random one.

  23. What is the C# equivalent to VB's exit sub?
  24. in C# return;

  25. What is the C# equivalent to VB's friend?
  26. Assembly level class member visibility in C# is ‘internal' I believe.

  27. Me, MyBase and MyClass…
  28. Me is what really symbolizes VB.NET isn’t it? Where is it really applicable ? Lets see:

    Many good examples...

  29. C# Equivalent of VB.NET MyClass???
  30. In otherwords, how do I force a method in my class to call the method implementations in the SAME class and not use any potentially overriden methods in derived classes?

  31. What's difference between f(const MyClass & in) and f(MyClass in)
  32. The equivalent of Global constants in VB
  33. but can anyone tell me how to simulate the concept of a global constant in a C# Windows app? The app in question contains several forms, each of which need to interrogate the value of a "global" constant. Do I have to create a class with a public constant declaration and instantiate that class from each form?

  34. C# equivalent of VB.NET Redim Preserve
  35. Does C# have an equivalent for VB.NET's Redim Preserve ? ReDim Preserve increases the final dimension of any array while preserving the array's contents (however, the type of the array may not be changed).

  36. Me vs. MyClass
  37. What is the difference between the Me and the MyClass keywords? I understand Me that it represents the specific instance of the class. When you're inside the object instance, it refers to itself using the Me keyword. What is the MyClass keyword used for?

  38. translate static in C# to VB.NET
  39. very good examples

  40. VB.Net program to demonstrate the 'MyClass' keyword
  41. Here, we will demonstrate the MyClass keyword. The MyClass keyword is used to refer to the current class name.

  42. Curious case of typeof in C# and VB.NET
  43. In this article one of the operator keyword which every .NET developer encounters named as typeof. But the purpose it servers in both of the languages is different.

    If you are the curious one to know how C# and vb.net treats typeof, continue reading the article.

  44. With End Block - VB.Net
  45. There is no direct equivalent to this in C#

  46. The My namespace
  47. One of the great new feature in Visual Basic 2005 is the My namespace.

    The My namespace doesn’t bring anything new to the language. It simply offers a clearer path to methods and properties already existing in the .Net Framework. You can see it as a shortcut to quickly access features that are sometime hard to find.

    This is the first article of a series of 2. Next month, I will show you how to extend this namespace with your own methods.

  48. Extending the My namespace
  49. This is the second (and last) article on the My namespace. Last month, I showed you what is the My namespace and how to use it. This month, I will show you how to extend it with your own methods. As you will soon discover, it is as simple as adding 2 lines to a class that you might already have written.

    Why extend this class? You surely built many helper functions over the years. Most of those functions are probably declared as static so that you don’t have to create an instance of the class to use them.

    The good news is that the My namespace can be extended so that your own classes can sit beside My.Application, My.Computer, My.User and so on.

  50. Distinguishing Visual Basic Me, My, MyBase, and MyClass
  51. I have been providing C# code for my articles for a long time now but not this month. The reason is that MyClass has no equivalent in that language. MyClass is purely VB.

    The easy one: My Let’s start with the easy one: My. The My keyword was introduced in the VB language with the .Net Framework 2.0 (TODO) and is simply a shortcut to often used .Net Framework classes. I have already covered this keyword in June 2007.

    The obvious one: Me This is the most often used keyword even if you don’t even always write it yourself because it is implicit from within an instance. In theory, the Me keyword is used to access the current instance.

    The common one: MyBase Sometimes, you don’t want to access to the current instance but you would prefer to refer to the base instance when you have overridden or shadowed a member. We very often see this keyword in constructors. We want to do everything the base constructor is doing and add something specific to the current instance in the derived class.

    Notice that if your classes inherits many levels deep, MyBase will call the members of the immediate base class (the one just above) and won’t go until the root.

    The obscure one: MyClass MyClass behaves mostly like Me. The only exception is that it will force to use the current instance of the class (and not any of its overrides) as if the members were declared as NotOverridable. In other words, MyClass makes sure that the member of the current class is dispatched and not the overridden member.

  52. Use Shared Keyword In VB.NET
  53. Shared keyword A shared method is not accessed via an object instance like a regular method, but rather is accessed directly from the class. The shared keyword in VB.NET is the equivalent of the static keyword in C#. In VB.NET, the shared keyword can only be applied to methods within a class, however, in C#, the static keyword can be applied to both methods within a normal class, and also at the class level to make the entire class static.

    Shared Variables When we share a value across all instances of a class when every object of a given type should share the same variable. This is accomplished through the use of shared variables.

    GDI+ in VB.NET

  54. Transformation In GDI+ In VB.NET
  55. A transformation is a process that changes graphics objects from one state to another. Rotation, scaling, reflection, translation, and shearing are some examples of transformation. Transformation can be applied not only to graphics shapes, curves, and images, but even to image colors.

  56. GDI+ IN VB.NET ARTICLES
  57. GDI+ IN VB.NET ARTICLES

No comments:

Post a Comment