Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All

Am running my below C# code and facing error in one point

Below is my C# code


C#
_lessons.Value = Convert.ToInt32((Information.IsNumeric(Request["edit_lessons"]) ? Request["edit_lessons"] : 0));
      _hours.Value = Convert.ToDecimal((Information.IsNumeric(Request["edit_hours"]) ? Request["edit_hours"] : 0));



Error:
C#
_lessons.Value = Convert.ToInt32((Information.IsNumeric(Request["edit_lessons"]) ? Request["edit_lessons"] : 0));
        _hours.Value = Convert.ToDecimal((Information.IsNumeric(Request["edit_hours"]) ? Request["edit_hours"] : 0));

The name 'Information' does not use in current context
Posted

C#
  int result;
_lessons.Value= Int32.TryParse(Request["edit_lessons"].ToString(), out result)?result:0;
 
Share this answer
 
Hi,

You need to qualify the use of the Microsoft.VisualBasic assembly, before you can directly reference its methods, something like:
C#
using Microsoft.VisualBasic;


Or you can reference the IsNumeric method by specifying it via it's full namespace, something like:
C#
Microsoft.VisualBasic.Information.IsNumeric


Have a look at the following article on C# Equivalent of VB's IsNumeric()[^]

... hope it helps.
 
Share this answer
 
v2
Rather than posting a question about every problem you come across, it would be far better for you to learn the basics of how to program. Get a book on c# and go through it from beginning to end. You can't learn a coding language by cutting an pasting code you don't understand then expecting people to fix it for you. You're not learning anything, and at worse you're just wasting people's time. We're not here to teach you how to write "Hello World".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900