ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

What is the difference between C#/Vb.Net properties and Methods?

user-image
تم إضافة السؤال من قبل Mohammad Riyazuddin , Web Developer , PYD, King Saud University
تاريخ النشر: 2016/05/19
Aceng Suparman
من قبل Aceng Suparman , Team Leader , Baker & McKenzie

Properties store data for an object, and methods are actions an object can be asked to perform

Mohammad Shahbaz
من قبل Mohammad Shahbaz

Both are essential part of object oriented programming. When class is created, it must have some attributes, e.g. humans have attributes like their height/weight/skin color etc. Now attributes alone are not sufficient to define a class, the actions or functionality the class performs, also needed to be specified.

Hence with that perspective, attributes are known as Properties and Functionality are known as Methods in C#/vb .net.

Doria Chanaz SEMMOUDI
من قبل Doria Chanaz SEMMOUDI , Chargée de projet , Mbis

Although there are differences between Visual Basic .NET and Visual C# . Net, both are first-class programming languages that are based on the Microsoft .NET Framework, and they are equally powerful. Visual Basic .NET is a true object-oriented programming language that includes new and improved features such as inheritance, polymorphism, interfaces, and overloading. Both Visual Basic .NET and Visual C# .NET use the common language runtime. There are almost no performance issues between Visual Basic .NET and Visual C# .NET. Visual C# .NET may have a few more "power" features such as handling unmanaged code, and Visual Basic .NET may be skewed a little toward ease of use by providing features such as late binding. However, the differences between Visual Basic .NET and Visual C# .NET are very small compared to what they were in earlier versions.

Tabassum Chamdiya
من قبل Tabassum Chamdiya , Software Engineer , Qualsoft Systems pvt ltd

In C# Void keyword is used when method return No value..In VB.Net Sub Keyword is used.

In C# default property can be defined by using Indexers.In VB.Net Default property can be defined by using Default

In C# object must be created using NEW.In VB>Net Object can be created using NEW and CreateObject()

Bineesh VP
من قبل Bineesh VP , Software Developer , Unknown

c# uses 'this' keyword where as it is 'me' keyword in vb.net.

 

c# code to declare a variable ; private int Number;

vb code to declare a variable : private Number as Integer

 

 

Method differences :

vb:  Private Function DoSomething() as Something()

c#  Private DoSomething()

 

VB usees keyword  'shared' instead of static keyword in c#

 

C# :  Public static DoSomething()

VB : Public Shared DoSomething() as Something()

 

arshad ep
من قبل arshad ep , SOFTWARE DEVELOPER , MH&DSolutions

Textbox1.Text - Text is the property Private Sub SetText() Textbox1.Text = "ZZZ" End Sub SetText() is a method. I think there's a technical difference between methods and procedures, but most people use the terms interchangeably. A function is a method that returns a value, as opposed to just doing something

Muhammad Ahsan Naeem
من قبل Muhammad Ahsan Naeem , IT Desktop Support , BINHINDI

Only Syntax is different rest it works the same.

Ishtiaq Ahmed
من قبل Ishtiaq Ahmed , Database Administrator , Excel Labs Pvt. Ltd.

There is no difference for properties and methods because both are running on same framework. You can search out for the syntax difference between VB.NET vs C#.NET.

http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

Abdullah Al Noman AAN
من قبل Abdullah Al Noman AAN , Network Administrator , Deutsche Gesellschaft für Internationale Zusammenarbeit (GIZ) GmbH

vb.net methods need no curly bracket while c#, curly braces are important for completing a method declaration

A C Handalage
من قبل A C Handalage , Tech Lead/ Project Coordinator , Srila Systems Pvt LTD

Methods are ment to be actions, where as properties ment to be data or fields

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟