serving the solutions day and night

Pages

Friday, April 23, 2010

C# Questions

struct vs Class
  • structs are value types that can contain data and functions
  • structs are value types and do not require heap allocation.
  • structs directly store their data in the struct, classes store a reference to a dynamically allocated object.
  • structs are useful for small data structures
  • structs can affect performance
  • Constructors are invoked with the new operator, but that does not allocate memory on the heap
  • A struct constructor simply returns the struct value itself (typically in a temporary location on the stack), and this value is then copied as necessary
  • With classes, multiple variables may have a reference to the same object
  • It is possible for operations on one variable to affect the object referenced by the other variable.
  • With structs, the variables each have their own copy of the data, and it is not possible for operations on one to affect the other.
  • structs do not support user-specified inheritance, and they implicitly inherit from type object
Public struct PointStruct
{
 public int x;
 public int y;

 public PointStruct(int x, int y)
 {
  this.x = x;
  this.y = y;
 }
}

static void Main(string[] args)
{
 PointStruct ps = new PointStruct();
 ps.x = 10;
 ps.y = 10;
 Console.WriteLine(“Initial struct values are “ + ps.x +”, “+ ps.y);
 ModifyStructPoint(ps);
 Console.WriteLine(“After ModifyStructPoint, struct values are “ + ps.x +”, “+ ps.y);
}

void ModifyStructPoint(PointStruct newStruct)
{
 newStruct.x = 20;
 newStruct.y = 20;
 Console.WriteLine(“Inside ModifyStructPoint()”);
 Console.WriteLine(“Modified values are “ + newStruct.x +”, “+ newStruct.y);
}

Initial struct values are 10,10
Inside ModifyStructPoint()
Modified values are 20,20
After ModifyStructPoint, struct values are 10,10
class PointClass
{
 public int x;
 public int y;

 public PointClass(int x, int y)
 {
 this.x = x;
 this.y = y;
 }
}

static void Main(string[] args)
{
 PointClass pc = new PointClass(10,10);
 Console.WriteLine(“Initial class values are “ + pc.x +”, “+ pc.y);
 ModifyClassPoint(pc);
 Console.WriteLine(“After ModifyClassPoint, class are “ + ps.x +”, “+ ps.y);
}

void ModifyClassPoint(PointStruct newPoint)
{
 newPoint.x = 20;
 newPoint y = 20;
 Console.WriteLine(“Inside ModifyClassPoint()”);
 Console.WriteLine(“Modified values are “ + newPoint.x +”, “+ newPoint.y);
}

Initial class values are 10,10
Inside ModifyClassPoint()
Modified values are 20,20
After ModifyClassPoint, struct values are 20,20


Saturday, April 10, 2010

Storing Images, Documents, FingerPrints, Signatures in Mysql (medium blob data type) using C# .Net

Storing Images, Documents, Fingerprints, Signatures in Mysql (medium blob data type) using C# .Net.
Mysql table structure, C# code  and Mysql tips.

Wednesday, April 7, 2010

Smart Card Java Card Technology

Java Card Technology - allows applets written in Java language to be executed on smart cards JCT provides JSRE (JC Runtime Environment)

Tuesday, April 6, 2010

XSL Code

1)Starting (From Database)
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="NewDataSet">
ALL CODE ARE GOING HERE
</xsl:template>
</xsl:stylesheet>

Sunday, April 4, 2010

C# Code

C# Functions
<%@ Page CodeBehind="about_us.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="localhost.about_us" %>

#region "Member Variables"
private int intUserID;
private string strSalutation;
private string strFName;
#endregion "Member Variables"

Saturday, April 3, 2010

ASP.NET State Management - Viewstate VS Session Variables


ASP.NET State Management - Viewstate VS Session Variables

ViewState

vscount.aspx
private int count;
protected void Page_Load(object sender, EventArgs e)
{
    count = Convert.ToInt32(ViewState["count"]);
}

protected void btnCount_Click(object sender, EventArgs e)
{
    count++;
    ViewState["count"] = count;
    lblView.Text = ViewState["count"].ToString();
}

protected void btnView_Click(object sender, EventArgs e)
{
    Response.Redirect("sesview.aspx");
}

ASP.NET State Management

ASP.NET State Management
A Web application is stateless. For example, by default if a user enters information into a text box on an HTML Web page, that information is sent to the server. However, it is not returned to the browser in the response. ASP.NET help you preserve data on both a per-page basis and an application-wide basis. These features are as follows:

  1. View state
  2. Control state
  3. Hidden fields
  4. Cookies
  5. Query strings
  6. Application state
  7. Session state
  8. Profile Properties

View state, control state, hidden fields, cookies, and query strings all involve storing data on the client in various ways.

Application state, session state, and profile properties all store data in memory on the server.


Regular Expressions

Pattern Description

Extension Methods, DataSet & DataReader

Extension methods help you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method.

For example, let us assume Car.dll is the 3rd party DLL and source is not available.
Car Class Library - Details.CS
namespace Car
{
    public class Details
    {
        public string Wheel(string cartype)
        {
            if (cartype=="CORROLA")
                return "Two";
            if (cartype == "JEEP")
                return "Four";
            else
                return "No Wheel";
        }
    }
}