Windows Phone Developers

Showing posts with label C# Error Handling. Show all posts
Showing posts with label C# Error Handling. Show all posts

Sunday, March 28, 2010

Invalid expression term '>'


Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Invalid expression term '>'

The error is most likely for some VB programmer coding C#. The following snippet shows you why:

Wrong

if (value.Length <> 0)



Correct

if (value.Length != 0)

or

if (value.Length > 0)



VB Programmers tend to use <>:) Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Saturday, October 11, 2008

Solution : An object reference is required for the nonstatic field, method, or property 'member'

Solution : An object reference is required for the nonstatic field, method, or property 'member'

class Program

{

static void Main(string[] args)

{

sayhello();

}

public void sayhello()

{

Console.WriteLine("Hello World!");

}

}

In order to use a non-static field, method, or property, you must first create an object instance.

static void Main(string[] args)

{

Program mp = new Program();

mp.sayhello();

mp.find_defaulter();

}

public void sayhello()

{

Console.WriteLine("Hello World!");

}





Non Static Error Dialog


C# Console Output Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Literal of type double cannot be implicitly converted to type 'decimal'; use an 'M' suffix to create a literal of this type

An assignment could not be completed; use a suffix to correct the instruction. The documentation for each type identifies the corresponding suffix for the type.

private void conversion_example()

{

int ivar = 1000;

decimal dvar = 0.15;

decimal ret_val;

ret_val = ivar * dvar;

}

Solution

private void conversion_example()

{

int ivar = 1000;

decimal dvar = 0.15M;

decimal ret_val;

ret_val = ivar * dvar;

}



Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Sunday, August 24, 2008

Argument '1': cannot convert from 'System.Text.StringBuilder' to 'string'

Use ‘ToString’ to convert the StringBuilder to String

// Appending String - using String Builder

System.Text.StringBuilder CompleteAddress1 = new

System.Text.StringBuilder();

CompleteAddress1.Append( "105, Annanagar ");

CompleteAddress1.Append( "Chennai ");

CompleteAddress1.Append( "Tamil Nadu ");

// Error Code

//MessageBox.Show(CompleteAddress1);

// corrected Code

MessageBox.Show(CompleteAddress1.ToString() );



Argument '1': cannot convert from 'System.Text.StringBuilder' to 'string' Error
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

A new expression requires (), [], or {} after type (C# Excel Application)

The new operator, used to dynamically allocate memory for an object, was not specified correctly. (Compiler Error CS1526)

Replace

oXL = new Microsoft.Office.Interop.Excel.application;

with

oXL = new Microsoft.Office.Interop.Excel.application();

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon