Welcome to Quadtechindia.com
Top 10 posts
Subject:
Differance Between VB.NET and C#
Body:
Advantages VB.NET :-
√ Has support for optional parameters which makes COM interoperability much easy.
√ With Option Strict off late binding is supported.Legacy VB functionalities can be
used by using Microsoft.VisualBasic namespace.
√ Has the WITH construct which is not in C#.
√ The VB.NET part of Visual Studio .NET compiles your code in the background.
While this is considered an advantage for small projects, people creating very large
projects have found that the IDE slows down considerably as the project gets larger.
Advantages of C#
√ XML documentation is generated from source code but this is now been incorporated
in Whidbey.
√ Operator overloading which is not in current VB.NET but is been introduced in
Whidbey.
√ Use of this statement makes unmanaged resource disposal simple.
√ Access to Unsafe code. This allows pointer arithmetic etc, and can improve
performance in some situations. However, it is not to be used lightly, as a lot of the
normal safety of C# is lost (as the name implies).This is the major difference that you
can access unmanaged code in C# and not in VB.NET.
By - AVINASH
===================================================================
Subject:
Boxing and Un-Boxing Example
Body:
Boxing is a process in which object instances are created and copy
values in to that instance.
Unboxing is vice versa of boxing operation where the value is copied from the instance in to
appropriate storage location.
Example:
Dim x As Integer
Dim y As Object
x = 10
‘ boxing process
y = x
‘ unboxing process
x = y
By - AVINASH
===================================================================
Subject:
Composition Example
Body:
internal class Piston {}
internal class Engine
{
private Piston[] myPistons = new Piston[4];
public bool Ignition() {
//some code
}
}
public class Car
{
private Engine myEngine = new Engine();
public void Start()
{
//put in keys etc..
if (myEngine.Ignition()) {
//some more code
}
}
}
By - BHUPEN
===================================================================
Subject:
Function to Open page in full screen mode
Body:
<script type="text/javascript">
function FullScreenMode(){
var win = window.open("", "full", "dependent=yes, fullscreen=yes");
win.location = window.location.href;
window.opener = null;
}
</script>
By - AVINASH
===================================================================
Subject:
Palindrom Program
Body:
public static void pali(string s)
{
bool status = false;
int i,j;
for (i = 0, j = s.Length-1; i < j; i++, j--)
{
if (s[i] != s[j])
{
status = true ;
}
}
if (status)
{
Console.WriteLine("The string is not palindrome");
}
else
{
Console.WriteLine("The string is palindrome");
}
}
By - BHUPEN
===================================================================
Subject:
To find Fibonacci Series
Body:
public static void fibonacci(int n)
{
int result = 0;
int a = 0, b = 1;
for (int i = 0; i < n; i++)
{
result = a + b;
Console.WriteLine(result);
a = b;
b = result;
}
}
By - BHUPEN
===================================================================
Subject:
To Find Factorial of Number
Body:
class factorial
{
public static int facto(int n)
{
if (n == 1)
return 1;
else if (n == 0)
return 0;
else return n * facto(n - 1);
}
}
By - BHUPEN
===================================================================
Subject:
Disable paste option of <asp:textbox> in asp.net
Body:
<asp:TextBox ID="TextBox3" runat="server" onpaste="return false" >
</asp:TextBox>
By - BHUPEN
===================================================================
Subject:
Login Window using database sql ser 2005
Body:
protected void Button1_Click(object sender, EventArgs e)
{
if (Authenticate())
{
Response.Redirect("sec.aspx");
}
else
{
ErrorMsg.Visible =true ;
}
}
public bool Authenticate()
{
bool authenticated = false;
SqlConnection con = new SqlConnection("Data Source=USER;Initial Catalog=tp;Integrated Security=True");
SqlCommand cmd = new SqlCommand("AuthenticateUser", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter userid = new SqlParameter("@username", SqlDbType.VarChar);
userid.Value = (UserName.Text).Trim();
SqlParameter pass = new SqlParameter("@password", SqlDbType.VarChar);
pass.Value = (password.Text).Trim();
SqlParameter isvalid = new SqlParameter("@isvalid", SqlDbType.Int);
isvalid.Direction = ParameterDirection.Output;
cmd.Parameters.Add(userid);
cmd.Parameters.Add(pass);
cmd.Parameters.Add(isvalid);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
if ((Convert.ToInt32(isvalid.Value)) == 1)
{
authenticated = true;
}
else
{
authenticated = false;
}
return authenticated;
}
<table border="2" cellpadding="6" class="style1">
<tr>
<td align="right"><font size="2"
face="Tahoma">User ID:</font></td>
<td><asp:textbox id="UserName" size="14" runat="server" Width="142px" /></td>
</tr>
<tr>
<td align="right"><font size="2"
face="Tahoma">Password:</font></td>
<td><asp:textbox id="password" size="14" runat="server" Width="142px"
TextMode="Password" />
</td>
</tr>
<tr>
<td colspan ="2" ><span lang="en-us">
</span>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Login "
Width="98px" />
<span lang="en-us"> </span></td>
</tr>
<tr>
<td colspan="2" align=center>
<span id="ErrorMsg" style="color:black;font:8pt verdana, arial" Visible=false runat=server>
<b>Invalid Account Name or Password!</b>
</span>
</td>
</tr>
</table>
By - BHUPEN
===================================================================
Subject:
Dynamically Select Dropdownlist item
Body:
You can bind the dropdown list dynamically in two ways, either by searching via text or value as shown below....
DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList.Items.FindByText(TextStringToSearchFor));
OR
DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList.Items.FindByValue(ValueStringToSearchFor));
Reply most welcome...
By - BHUPEN
===================================================================