List of Keywords in Visual Studio C Sharp
abstract
as
base
bool
break
Byte
case
catch
char
checked
class
const
continue
decimal
default
delegate
do
double
else
enum
event
explicit
extern
false
finally
fixed
float
for
foreach
goto
if
implicit
in
int
interface
internal
is
lock
long
namespace
new
null
object
operator
out
override
params
private
protected
public
readonly
ref
return
sbyte
sealed
short
sizeof
stackalloc
static
string
struct
switch
this
throw
true
try
typeof
uint
ulong
unchecked
unsafe
ushort
using
virtual
volatile
void
while
Use of Comments in Programming
This question may be arising in your mind about comment word. You might be thinking that why to use the comment in the program and what is the use of comments? Whether it is a part of program or whether it is important to add comment for running of the program so I will answer all your doubt in your mind.
Comments are unexecutable part of any program written in any language.It is added in programs just for reference.
Suppose you have written a 100+ line program to get a Output.Well you might be knowing the full program right now.But what if others will open your program and try to understand.He may not understand your program because may be he is a new programmer or any other reason.
So,Comments are added after some line to show why this concept is used here for the future reference so that if you or any other person will open that particular program then he can understand the whole program if you have inserted comments at important lines of the program.
So,My advice is to use comment /* comment */ so that it will be beneficial in the future to understand your past program.
Tips: You can right any thing starting with // or /// to show as a comment or you can also use /* wrie here */ to write your comments for that program.
This is all about Comments.If you have any comment then please share here.
Thank you.
Pankaj Gupta
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
index1.Text = DropDownList1.SelectedIndex.ToString();//this coe is writen to display defaut item of dropdown
text1.Text = DropDownList1.SelectedItem.Text;//remove this code and see the result
value1.Text = DropDownList1.SelectedValue;//
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
index1.Text = DropDownList1.SelectedIndex.ToString();
text1.Text = DropDownList1.SelectedItem.Text;
value1.Text = DropDownList1.SelectedValue;
}
protected void Button1_Click(object sender, EventArgs e)
{
DropDownList1.Items.RemoveAt(Convert.ToInt16(DropDownList1.SelectedIndex.ToString()));
/* these button do nothing but kept fort autopostback as to display content in
DropDownList1_SelectedIndexChanged as these need postback to do so;
IMP--> Inorder not to INCLUDE button make AutoPostBack property of drpp true
*/
}
}
Public Function SwapTable(ByRef dt As DataTable, ByVal col As Integer) As DataTable
Try
Dim dtTemp As New DataTable
Dim inti, intj As Integer
dtTemp.Columns.Clear()
dtTemp.Columns.Add(dt.Columns(col).Caption)
For inti = 0 To dt.Columns.Count - 1
If inti = col And inti 0 Then
'If dt.Columns(0).Caption.Trim "DC_NOHID" Then
dtTemp.Columns.Add(dt.Columns(0).Caption)
'Else
' dtTemp.Columns.Add(dt.Columns(1).Caption)
'End If
End If
If inti col And inti 0 Then
dtTemp.Columns.Add(dt.Columns(inti).Caption)
End If
Next
Dim Dr As DataRow
For intj = 0 To dt.Rows.Count - 1
Dr = dtTemp.NewRow
Dr.Item(0) = dt.Rows(intj).ItemArray(col)
Dr.Item(col) = dt.Rows(intj).ItemArray(0)
inti = 1
While inti < dt.Columns.Count
If inti 0 And inti col Then
Dr.Item(inti) = dt.Rows(intj).ItemArray(inti)
End If
inti += 1
End While
dtTemp.Rows.Add(Dr)
Next
dt.Clear()
dt = dtTemp.Copy
For inti = 0 To dt.Columns.Count - 1
dt.Columns(inti).ReadOnly = True
dt.DefaultView.Sort = dt.Columns(0).ColumnName
Next
Return dt
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Msg")
End Try
End Function
#Region "ExporttoPDF"
Public Sub ExportToPDF2(ByVal strRptName As String)
Dim strParam As String = ""
Dim strPath As String = Application.StartupPath
Dim objFS As Object
Dim strPDF As Boolean = True
Dim strDt_Fr As String = ""
Dim strDt_To As String = ""
Dim strEmployee_CD As String = ""
Dim strNewName As String = ""
Dim strOriginal, strOrignalPath, strNewRootName, strPDFName As String
Dim strUniqueSuffix As String
Dim strFormula As String
If InStr(strPath, "bin", CompareMethod.Text) > 0 Then
strRptPath = strPath.Substring(0, InStr(strPath, "bin", CompareMethod.Text) - 1)
Else
strRptPath = strPath
End If
If strRptPath.EndsWith("\") Then
Else
strRptPath = strRptPath & "\"
End If
Const ForReading = 1, ForWriting = 2, ForAppending = 8
strOriginal = strRptPath
objFS = CreateObject("Scripting.FileSystemObject") ' Creating the instance of the FileSystem object form the scripting object.
strRptPath += "Reports\PDF"
Dim f, f1, fc, s
f = objFS.GetFolder(strRptPath)
fc = f.Files
Dim p() As System.Diagnostics.Process = Process.GetProcesses(Dns.GetHostName)
Dim i As Integer
For i = 0 To p.Length - 1
If p(i).ProcessName.Trim = "AcroRd32" Then
p(i).Kill()
Exit For
End If
Next
For Each f1 In fc
If objFS.FileExists(strRptPath & "\" & f1.name) Then
objFS.DeleteFile(strRptPath & "\" & f1.name, True)
End If
Next
strUniqueSuffix = "RptTest001" & Hour(Now) & Minute(Now) & Second(Now)
strOrignalPath = strOriginal & "Reports\" & strRptName
'strParam = "EMPCODE=" & strEmployee_CD & "" & "^^" & "FROM_DT=" & strDt_Fr & "" & "^^" & "TO_DT=" & strDt_To & ""
'strParam = "FROM_DT=" & strDt_Fr & "" & "^^" & "TO_DT=" & strDt_To & "" & "^^" & "EMPCODE=" & strEmployee_CD & "" & "^^" & "FIN_YR=" & fin_yr & ""
'strParam = "FROM_DT=" & strDt_Fr & "" & "^^" & "TO_DT=" & strDt_To & "" & "^^" & "EMPCODE ='1'" '& strEmployee_CD & ""
If objFS.FileExists(strOrignalPath) Then
strNewRootName = "Reports\PDF\" & strUniqueSuffix
strNewName = strOriginal & strNewRootName & ".rpt"
objFS.CopyFile(strOrignalPath, strNewName, True)
End If
Dim oPDFFile
Dim bFileConverted
oPDFFile = CreateObject("RPTToPDF.ExportToPDF")
bFileConverted = oPDFFile.PopulateRPT(strOriginal & strNewRootName, strNewName, strParam, strFormula)
'MsgBox(oPDFFile.mParamDesc2)
'MsgBox(oPDFFile.mparamDesc1)
If objFS.FileExists(strNewName) Then
objFS.DeleteFile(strNewName, True)
End If
strPDFName = strOriginal & strNewRootName & ".pdf"
Try
If bFileConverted Then
Process.Start(strPDFName)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
#End Region