Cyberiafreak

"Fortunate are those who take the first steps.” ― Paulo Coelho

WinFX Beta 2 is Released

Today MS released new Version of

(1) Windows Vista Beta 2,

 (2) Longhorn Server Beta 2,

 (3) Office 2007 Beta 2

(4) WinFX Beta 2.

 You can download WinFX Beta 2 here

http://msdn.microsoft.com/windowsvista/downloads/products/getthebeta/

~Mahe

Advertisements

May 25, 2006 Posted by | WinFX | Leave a comment

String to Int and Int to Stri- without using builtin library

Hi all,

            Interestingly this is going to be big post on normal datatype conversion but without using any BUILTIN FUNCTION OR LIBRARIES in .NET.

 

Yes, When we need to convert int-> string or vice versa…we used to use toString(), Parse, ConvertTo. .etc..functions to do this task. But I had this doubt when I was going through MS Interview questions. Yes, In Microsoft, they’ve asked this type of questions .. to test the basic knowledge of core programming….but I ‘ve taken 4 days(part time) to comeout with solutions for this after discussing with my colleagues( Jayveer & Vaibhav).

I’m sure about it technicallity or the way I’ve coded..but not sure about the possibility of doing the same in any other way. If you know something about hardcore conversion or links pls leave it in comment..

 

//Issue Topic: DataType conversion in C# ( How compiler/inbuilt function doing the same…? )

// To convert to data type without using any inbuily function provided by the Framework

//Logic : Compiler Level

//Language used : C#

// CODE Written By : Mahesh

// Courtesy : XOR Algorithm / Idea by  :mladenp

// For String reversing…http://weblogs.sqlteam.com/mladenp/archive/2006/03/19/9350.aspx?Pending=true

 

/////////////////////////// STRING -> INT/////////////////////////////////////////

using System;

namespace Mystring

{

    class Program

    {

        static void Main(string[] args)

        {

            # region STRING -> INT

            string strInput = "300";

            int intOutput = 0;

            for (int i = 0; i < strInput.Length; i++)

            {

                intOutput = intOutput * 10;

                intOutput = intOutput + strInput[i] – 48;

            }

            Console.WriteLine("Input is string ->300 and ouput is Integer->" + intOutput.ToString()); 

            Console.WriteLine("");

            # endregion

/////////////////////////// INT -> STRING/////////////////////////////////////////

            # region INT -> STRING

            int intIndex = 1;

            int intInput = 23456;

            string strResult = "";

            while (intIndex > 0)

            {

                if (intInput == 0)

                    break;

                intIndex = intInput % 10;

                intInput = intInput / 10;

                strResult += intIndex;

            }

 

      //Actual string reverse is happening here

            char[] chr = strResult.ToCharArray();

            int intLen = strResult.Length – 1;

            for (int i = 0; i < intLen; i++, intLen–)

            {

                //using XOR – Refer the XOR Table below

                chr[i] ^= chr[intLen];

                chr[intLen] ^= chr[i];

                chr[i] ^= chr[intLen];

            }

            string strRes = new string(chr);

            Console.WriteLine("Input is Int ->23456 and ouput is String->" + strRes);

            Console.WriteLine("");

        # endregion

        }

    }

}

 

//XOR table

//1 1    0

//0 0    1

//1 0    1

//0 1    1

 

Hope I’ve managed to get the conversion successfully...pls let me know I missed out something or anyother logic to the same..and also feel free to drop ur comment about my expedition on this…

 

Mahesh

mfcmahesh at hotmail.com

May 23, 2006 Posted by | My .NET Expedition - Revealed | Leave a comment

Common Errors in English –

I’m immensely enjoying this link..
http://www.wsu.edu/%7Ebrians/errors/errors.html#errors

Nice collections..worth to click it.

Mahes

May 23, 2006 Posted by | Power Toys - Personal | Leave a comment

CodePlex – new MS community to share

What is CodePlex?

      Microsoft started a new community to share, join or start new projects.and is in beta. Projects like the ATLAS Control Toolkit or Commerce Starter Kit are already included in that section.

     CodePlex is an online software development environment for open and shared source developers to create, host and manage projects throughout the project lifecycle. It has been written from the ground up in C# using .NET 2.0 technology with Team Foundation Server on the back end.

CodePlex is open to the public free of charge.

  www.codeplex.com

 I read from someone’s blog about this..it is one more GOTDOTNET site from MS for supporitng Community…let wait and see…what you think about this..will it create buzz..?

rgds,

Mahes

May 18, 2006 Posted by | .NET General | Leave a comment

Diff between & and && , | and ||

Hi all..

Today I had a confusion in using conditional operator. Normally I used to use ‘&&’ or ‘||’ for checking boolean condition. But when I was going through sample…I stumble to see & everwhere…but functionality wise both are ok.

Then what is the diff between these two operators ( & and && ) , (| and || )..

//EXAMPLE

private void Form1_Load(object sender, EventArgs e)

{

          int val2=10,val3=20;

          bool val1 = false;

         val1 = (val2 != 0) && (val3 / val2 > 2); // always use && ——- case (i)

         val1 = (val2 != 0) & (val3 / val2 > 2); // dont use & ————case (ii)

}

case(i) If the value of the first operand of the && operator is false, then there is no need to consider the value of the second operand because the result will be false regardless. Similarly, the || operator will return true if its first operand is true, regardless of the value of the second operand.

case

(ii) In these, both operands will always be evaluated.  

 

In conditional evaluation of operands, you will see a small performance increase if you use && and || instead of & and |.  As a rule of thumb, always use && and || where possible.

 

Happy validating..

Mahes

May 12, 2006 Posted by | .NET General | 1 Comment

Free VS Partner Product DVD

Hi all.
 
Free DVD and receive over 50 tools, components and languages from Visual Studio Industry Partners. These full, trial and and evaluation products can help save you time and money building applications for Microsoft Windows, mobile devices, the Web, and Web services.
 
To receive your free resource DVD, please click on the appropriate order button for your location.
 
Cheers !!
Mahesh~

May 8, 2006 Posted by | .NET General | Leave a comment

Passing values between Winforms – C# (Tried all ways..!!)

Hi all,
 Back 2 basic …yes.but interesting…I had a doubt in my mind for very long time about sharing a values between 2 winforms…Most of know in webforms…but this is something diff…I had the same kind of requirement in Dicom viewer project but I simply solved it for time being without clearing myself..but here I’ve cleared and tried all possible ways. pls free to comment here if I’m wrong or anyother ways of doing the same.
 
(1) Set the access modifier to Public for that control to access in Form1
In form1
Form2 f=new Form2();
f.textBox1.Text =textBox1.Text;
f.Show();
In form2
 public System.Windows.Forms.TextBox textBox1;
 
 (2) By using a Public property in Form2
 In form1
 Form2 f=new Form2();
f.textBox1.Text =textBox1.Text;
 f.Show();
In form2
private string m_TempText = "";
public string TempText
{
get { return m_TempText; }
 set { m_TempText = value; textBox1.Text = m_TempText; }
 }
 
 (3) Passing thru Form2 contructor
In form1
Form2 fg=new Form2(textBox1.Text);
fg.Show();
 In form2
public Form2(string s)
{
InitializeComponent();
textBox1.Text =s;
 }
 
(4) Assiging the Form2 object with Form1 Object
 In form1
public System.Windows.Forms.TextBox textBox1;
 Form2 f=new Form2();
 f.frm1inForm2=this;
 f.ShowDialog();
 In form2
  public class Form2 { public Form1 frm1inForm2; }
  private void Form2_Load(object sender, System.EventArgs e) { this.textBox1.Text = ((Form1)    this.frm1inForm2).textBox1.Text; }
 
 If you guys knows anyother method for doing the same thing…pls share it here..
 
Mahesh
 

May 3, 2006 Posted by | .NET General | Leave a comment