Archive

Archive for September, 2010

Please write a sample program that parses the string into a series of substrings


//Questions:

//Please write a sample program that parses the string into a series of substrings where the delimiter between the substrings is “^*!%~” and then reassembles the strings and delimiters into a single new string where each of the substrings is in the reverse order from the original string. The method must return the final string.

//Original String:

//Token A^*!%~Token B^*!%~Token C^*!%~Token D^*!%~Token E

//Output String:

//Token E^*!%~Token D^*!%~Token C^*!%~Token B^*!%~Token A

//using System.Text;

string strOriginalString = “Token A^*!%~Token B^*!%~Token C^*!%~Token D^*!%~Token E”;

string[] strSeperator = new string[1];

strSeperator[0] = “^*!%~”;

string[] strArrayIndividualStrings = strOriginalString.Split(strSeperator, StringSplitOptions.RemoveEmptyEntries);

int intLengthOfStringArray = strArrayIndividualStrings.Length;

StringBuilder sbOutputString = new StringBuilder();

for (int i = (intLengthOfStringArray – 1); i >= 0; i–)

{

if (i != 0)

{

sbOutputString.Append(strArrayIndividualStrings[i] + strSeperator[0]);

}

else

{

sbOutputString.Append(strArrayIndividualStrings[i] + “”);

}

}

Response.Write(“Original String : ” + strOriginalString);

Response.Write(“
“);

Response.Write(“reversed String : ” + sbOutputString);

http://venkataspinterview.blogspot.com/2008/07/aspnet-interview-questions.html

http://venkatcsharpinterview.blogspot.com/2009/07/c-interview-questions-related-to.html

Advertisements
Categories: Uncategorized

String Array 2D

Categories: Uncategorized

SharePoint RTE is missing for some users…


Go to SharePoint Site…

Site Settings
Site permissions
Permission Levels
Click on :Contribute
Under Site Permissions :
Check : Add and Customize Pages – Add, change, or delete HTML pages or Web Part Pages, and edit the Web site using a Microsoft SharePoint Foundation-compatible editor

 

Now go to Site Settings

People and Group

Search for…”Members” group..

Ex: Your site collection Name Members

Click New

Add user

Enter user name who are not able to see RTE..

Ok

Now you will able to see RTE

 

Categories: Uncategorized

Authentication


string strLoginUser = string.Empty;

protected void Page_Load(object sender, EventArgs e)

{

//Response.Write(“hi”);

System.Security.Principal.WindowsIdentity win = default(System.Security.Principal.WindowsIdentity);

win = System.Security.Principal.WindowsIdentity.GetCurrent();

string _UserName = win.Name.Substring(win.Name.IndexOf(“\\”) + 1);

strLoginUser = _UserName;

Response.Write(strLoginUser);

Response.Write(“
“);

Response.Write(win.Name.ToString());

}

protected void Button1_Click(object sender, EventArgs e)

{

if (this.TextBox1.Text.Trim() == “HR_manager” && this.TextBox2.Text.Trim() == “password”)

{

// Success, create non-persistent authentication cookie.

FormsAuthentication.SetAuthCookie(this.TextBox1.Text.Trim(),false);

FormsAuthenticationTicket ticket1 =

new FormsAuthenticationTicket(

1, // version

this.TextBox1.Text.Trim(), // get username from the form

DateTime.Now, // issue time is now

DateTime.Now.AddMinutes(10), // expires in 10 minutes

false, // cookie is not persistent

“HR” // role assignment is stored

// in userData

);

HttpCookie cookie1 = new HttpCookie(

FormsAuthentication.FormsCookieName,

FormsAuthentication.Encrypt(ticket1));

Response.Cookies.Add(cookie1);

// 4. Do the redirect.

String returnUrl1;

// the login is successful

if (Request.QueryString[“ReturnUrl”] == null)

{

returnUrl1 = “HR_main.aspx”;

}

//login not unsuccessful

else

{

returnUrl1 = Request.QueryString[“ReturnUrl”];

}

Response.Redirect(returnUrl1);

}

}

Categories: Uncategorized

Which browser You are using

Categories: Uncategorized

C# CPU Usage

Categories: Uncategorized

Currency Convert


protected void Button1_Click(object sender, EventArgs e)

{

//int k = Convert.ToInt32(TextBox1.Text);

//Response.Write(string.Format(“String Format Function to Convert to Number Format: {0:000,000.00}
“, k));

decimal decValue = Convert.ToDecimal(TextBox1.Text);

string k1 = String.Format(“{0:000,000.00}”, decValue);

char[] MyChar = { ‘ ‘, ‘0’ };

k1 = k1.TrimStart(MyChar);

char[] MyChar2 = { ‘ ‘, ‘,’ };

k1 = k1.TrimStart(MyChar2);

TextBox1.Text = k1;

}
============================================================
function formatCurrency(num) {

num = num.toString().replace(/\$|\,/g,”);

if(isNaN(num))

num = “0”;

sign = (num == (num = Math.abs(num)));

num = Math.floor(num*100+0.50000000001);

cents = num%100;

num = Math.floor(num/100).toString();

if(cents<10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4*i+3))+','+

num.substring(num.length-(4*i+3));

return (((sign)?'':'-') + '$' + num + '.' + cents);

}

Categories: Uncategorized