+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: cegonsoft private limited | Overloading of Constructors in VB.NET

  1. #1

    Default cegonsoft private limited | Overloading of Constructors in VB.NET

    Overloading Constructors

    Since, constructors are a special type of method ( a sub procedure), we can overload constructors .

    Class Person
    Private name As String
    Public Sub New()
    name = "uknown"
    End Sub
    Public Sub New(ByVal theName As String)
    name = theName
    End Sub
    End Class

    Now, if we create an object like

    Dim thePerson As New Person()

    First the constructor will be called initializing the name with "unknown" and if we create an object like

    Dim thePerson As New Person("XYZ")

    The constructor will be called initializing the name with "XYZ".

    As you can see, overloading methods and constructors gives your program a lot of flexibility and reduces a lot of complexity that would otherwise be produced if we had to use different name for these methods.


    Visit: Cegonsoft
    Last edited by amitksaa; 09-22-2011 at 11:57 AM.

  2. #2

    Default

    Overloading Constructors
    Constructors provide initialization code when you instantiate objects in Visual Basic .NET or in Visual Basic 2010. If you overload the constructor of a Visual Basic object, you can alter this instantiation process. For example, if you overload the constructor of a class, you can initialize values for properties.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim Sedan As New Vehicle()
    MessageBox.Show (Sedan.NumberOfWheels.ToString)
    Dim TractorTrailer As New Vehicle(18)
    MessageBox.Show (TractorTrailer.NumberOfWheels.ToString)
    End Sub

    Public Class Vehicle
    Private m_Wheels As Integer
    Sub New() 'Default Constructor
    m_Wheels = 4
    End Sub
    Sub New(ByVal NumberOfWheels As Integer) 'Overloaded Constructor
    m_Wheels = NumberOfWheels
    End Sub
    Public Property NumberOfWheels()
    Get
    Return m_Wheels
    End Get
    Set(ByVal Value)
    m_Wheels = Value
    End Set
    End Property
    End Class
    In cegonsoft training all advanced concepts are trained ..

  3. #3

    Default

    View state in VB.NET

    Viewstate is a built-in structure for automatically retaining values amongst the multiple
    requests for the same page. The viewstate is internally maintained as a hidden field on the
    page but is hashed, providing greater security than developer-implemented hidden fields
    do.

    Performance of viewstate varies depending on the type of server control to which it is
    applied. Label, TextBox, CheckBox, RadioButton, and HyperLink are server controls
    that perform well with ViewState. DropDownList, ListBox, DataGrid, and DataList suffer
    from poor performance because of their size and the large amounts of data making
    roundtrips to the server.

    Following are the benefits of using View state:-

    1. No server resources are required because state is in a structure in the page code.
    2. Simplicity.
    3. States are retained automatically.
    4. The values in view state are hashed, compressed, and encoded, thus representing a higher state of security than hidden fields.
    5. View state is good for caching data in Web frame configurations because the data is cached on the client.

    Following are limitation of using View state:-

    1. Page loading and posting performance decreases when large values are stored because view state is stored in the page.
    2. Although view state stores data in a hashed format, it can still be tampered because it is stored in a hidden field on the page. The information in the hidden field can also be seen if the page output source is viewed directly, creating a potential security risk.

    Below is sample of storing values in view state.

    me.ViewState["EnterTime"] = DateTime.Now.ToString()

    Cegonsoft

  4. #4

    Default

    Software testing is for the checkin the detect faults.
    Through the software testing establish confidence in software and evaluate properties of software
    Reliability
    Performance
    Memory Usage
    Security
    Usability

    So the software testing is the very important one work in the project development.
    Through which only we provide the very good quality product to clients and satisfies the client needs.

    In cegonsoft they provide very good training for the software testing.They provide the training in all the advance tools.
    So which the students get the good opportunity in the industry to get placement.

    Cegonsoft

  5. #5

    Default

    Cegonsoft provides the very good training in the technology wise.They provide the technology training on the basis of the industry standard.So that the cegonsoft trained peoples get the good placement and also they get the the good knowledge in their desired field.
    In cegonsoft they provide the soft skill training.In this training the HR mold the students based on the industry standard.
    They provide the good placement opportunity also so that the students in the cegonsoft get the opportunity to attend the many companies..
    Cegonsoft

  6. #6

    Default

    Example for constructor overloading
    Imports System

    Public Class MainClass

    Shared Sub Main(ByVal args As String())
    ' use overloaded constructors
    Dim time1 As New CTime2()
    Dim time2 As New CTime2(2)
    Dim time3 As New CTime2(21, 34)
    Dim time4 As New CTime2(12, 25, 42)
    Dim time5 As New CTime2(27, 74, 99)
    Dim time6 As New CTime2(time4) ' use time4 as initial value

    Const SPACING As Integer = 13 ' spacing between output text

    Console.WriteLine( "Constructed with: " & vbCrLf & _
    " time1: all arguments defaulted" & vbCrLf & _
    Space(SPACING) & time1.ToUniversalString() )

    ' invoke time2 methods
    Console.WriteLine( " time2: hour specified; minute and second defaulted" & _
    vbCrLf & Space(SPACING) & _
    time2.ToUniversalString() )

    ' invoke time3 methods
    Console.WriteLine( " time3: hour and minute specified; second defaulted" & _
    vbCrLf & Space(SPACING) & time3.ToUniversalString() )

    ' invoke time4 methods
    Console.WriteLine( " time4: hour, minute and second specified" & _
    vbCrLf & Space(SPACING) & time4.ToUniversalString() )

    ' invoke time5 methods
    Console.WriteLine( " time5: hour, minute and second specified" & _
    vbCrLf & Space(SPACING) & time5.ToUniversalString() )

    ' invoke time6 methods
    Console.WriteLine( " time6: Time2 object time4 specified" & vbCrLf & _
    Space(SPACING) & time6.ToUniversalString() )


    End Sub
    End Class


    ' Represents time and contains overloaded constructors.
    Class CTime2
    Inherits Object

    Private mHour As Integer ' 0 - 23
    Private mMinute As Integer ' 0 - 59
    Private mSecond As Integer ' 0 - 59

    ' constructor initializes each variable to zero and
    ' ensures that each CTime2 object starts in consistent state
    Public Sub New()
    SetTime()
    End Sub ' New

    ' CTime2 constructor: hour supplied;
    ' minute and second default to 0
    Public Sub New(ByVal hourValue As Integer)
    SetTime(hourValue)
    End Sub ' New

    ' CTime2 constructor: hour and minute supplied;
    ' second defaulted to 0
    Public Sub New(ByVal hourValue As Integer, _
    ByVal minuteValue As Integer)

    SetTime(hourValue, minuteValue)
    End Sub ' New

    ' CTime2 constructor: hour, minute and second supplied
    Public Sub New(ByVal hourValue As Integer, _
    ByVal minuteValue As Integer, ByVal secondValue As Integer)

    SetTime(hourValue, minuteValue, secondValue)
    End Sub ' New

    ' CTime2 constructor: another CTime2 object supplied
    Public Sub New(ByVal timeValue As CTime2)
    SetTime(timeValue.mHour, timeValue.mMinute, timeValue.mSecond)
    End Sub ' New

    ' set new time value using universal time;
    ' perform validity checks on data;
    ' set invalid values to zero
    Public Sub SetTime(Optional ByVal hourValue As Integer = 0, _
    Optional ByVal minuteValue As Integer = 0, _
    Optional ByVal secondValue As Integer = 0)

    ' perform validity checks on hour, then set hour
    If (hourValue >= 0 AndAlso hourValue < 24) Then
    mHour = hourValue
    Else
    mHour = 0
    End If

    ' perform validity checks on minute, then set minute
    If (minuteValue >= 0 AndAlso minuteValue < 60) Then
    mMinute = minuteValue
    Else
    mMinute = 0
    End If

    ' perform validity checks on second, then set second
    If (secondValue >= 0 AndAlso secondValue < 60) Then
    mSecond = secondValue
    Else
    mSecond = 0
    End If

    End Sub ' SetTime

    ' convert String to universal-time format
    Public Function ToUniversalString() As String
    Return String.Format("{0}:{12}:{22}", _
    mHour, mMinute, mSecond)
    End Function ' ToUniversalString


    End Class

    cegonsoft

  7. #7
    Emerald Star member madhusundar is on a distinguished road
    Join Date
    Sep 2011
    Posts
    104

    Default

    The .NET framework created by Microsoft is a software development platform that focuses on rapid application development, platform independence and network transparency.

    .NET is Microsoft's strategic initiative for server and desktop development for the next decade.

    According to Microsoft, .NET includes many technologies that are designed to facilitate rapid development
    of Internet and Intranet applications. .NET-connected solutions aim to enable businesses integrate theirsystems more rapidly and in a more agile manner and help them realize the promise of information anytime, anywhere, on any device.



    ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server.

    ASP.NET is a Microsoft Technology
    ASP stands for Active Server Pages
    ASP.NET is a program that runs inside IIS
    IIS (Internet Information Services) is Microsoft's Internet server
    IIS comes as a free component with Windows servers
    IIS is also a part of Windows 2000 and XP Professional


    The .NET Framework is the infrastructure for the Microsoft .NET platform.

    The .NET Framework is an environment for building, deploying, and running Web applications and Web Services.



    Cegonsoft
    Last edited by madhusundar; 10-01-2011 at 10:30 AM.

  8. #8

    Default

    Hi,
    While having nice reviews, Cegonsoft is the best IT training centre who makes freshers to learn and understand various technologies quickly and easily and also place them in various multinational companies .They have Experienced and Intelligent Tech Consultants who puts a lot of effort and hard work to make all these possible. The HR team has also doing very nice work to provide Soft Skills and guide students according to the Corporate Standard requirements and as a result most of the students are getting placement right after training.

    Cegonsoft

  9. #9

    Default

    I was seeking for this program..
    Cegonsoft

  10. #10

    Default

    Overloaded Constructors

    When you instantiate a new object in Visual Basic. NET calls the new implicit method. If you do not you write a new method, Visual Basic. NET builds for you. If you want to initialize all the variables of an object when you create a new object, you can write a new method of overload. You can then transfer one or more values ​​of this new method. You will probably find that the new method overloading is the most common use of overloading.

    Open the Line.vb class module and add the code shown below.
    Public Sub New()
    ' Do Nothing
    End Sub

    Public Sub New(ByVal Line As String)
    mstrLine = Line
    End Sub

    cegonsoft

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts