SIGN UP MEMBER LOGIN:    
ARTICLE

How to Write a Method in C#?

Posted by Ahmed Abdel Ghany Articles | C# Language September 23, 2004
This sample shows to write a windows application that gives you the - C# - method throw a simple 4 steps.
Reader Level:
Download Files:
 

In this sample I wrote a windows application that gives you the C# method throw a simple 4 steps. I think that will be useful for the beginners to C# programming, and will help them to learn how to write a method in C#. This is the V 1.0 of the application I will write the enhanced V 1.1 that will enables you to add parameters to your method .

Login to add your contents and source code to this article
share this article :
post comment
 

Hi, i have one ready made function in VB.Net but i want to use it in C#.Net.
So tell me converted Code.

The code is,

Imports System.Convert

Partial Class EncDec
    Inherits System.Web.UI.Page

  

    Public Function SimpleEncrypt(ByVal TheText As String) As String
        Dim tempChar As String = Nothing
        Dim i As Integer = 0
        For i = 1 To TheText.Length
            If ToInt32(TheText.Chars(i - 1)) < 128 Then
                tempChar = System.Convert.ToString(ToInt32(TheText.Chars(i - 1)) + 100)
            ElseIf ToInt32(TheText.Chars(i - 1)) > 128 Then
                tempChar = System.Convert.ToString(ToInt32(TheText.Chars(i - 1)) - 100)
            End If
            TheText = TheText.Remove(i - 1, 1).Insert(i - 1, (CChar(ChrW(tempChar))).ToString())
        Next i
        Return TheText
    End Function

    Protected Sub butSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles butSubmit.Click
        If TextBox1.Text = "admin" Then
            txtResult.Text = SimpleEncrypt(txtText.Text)
        Else
            Label1.Text = "Enter Correct Password"
        End If

        'txtResult.Visible = True
        'butDecrypt.Visible = True
        'txtText.Visible = False
        'butSubmit.Visible = False
    End Sub

    Protected Sub butDecrypt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles butDecrypt.Click
        If TextBox2.Text = "admin" Then
            txtText.Text = SimpleEncrypt(txtResult.Text)
        Else
            Label1.Text = "Enter Correct Password"

        End If

        'txtText.Visible = True
        'butSubmit.Visible = True
        'txtResult.Visible = False
        'butDecrypt.Visible = False
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
End Class

Posted by Pranjal Talele Nov 23, 2010
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor