Functions and Subroutines in C#.Net

InfoPath alternatives for form designing SharePoint

Functions and subroutines (subs) are very similar; both enable you to create a reusable block of code that you can call from other locations in your application. The difference between a function and a subroutine is that a function can return data whereas a sub doesn’t. Together, functions and subroutines are referred to as methods. You can also check here what is log4net ?

They can be parameterized. That is, you can pass in additional information that can be used inside the function or subs.

‘ Define a function
Public Function FunctionName ([parameterList]) As DataType
End Function

‘ Define a subroutine
Public Sub SubName ([parameterList])
End Sub

// Define a function
public datatype FunctionName([parameterList])

// Define a subroutine
public void SubName([parameterList])

The complete first line, starting with Public, is referred to as the method signature because it defines the look of the function, including its name and its parameters. The Public keyword (public in C#) is called an access modifier and defines to what extent other web pages or code files can see this method.

The name of the function is followed by parentheses, which in turn can contain an optional parameter list. Both the function and subroutine have a parameter list that enables you to define the name and data type of variables that are passed to the method. Inside the method you can access these variables as you would normal variables.

Similar SharePoint 2013 Tutorials

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →

Leave a Reply