How To Add IsNumneric Function in C#

That’s right, you can call VB’s IsNumeric() function directly from C#. First add a reference to the Visual Basic compatibility assembly, Microsoft.VisualBasic.dll, which contains the function’s implementation: import namespace using Microsoft.VisualBasic;

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="IsNumneric.aspx.cs" Inherits="IsNumneric" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
   <title>Untitled Page</title>
   <form id="form1" runat="server">
           <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
           <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
           <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.VisualBasic;

public partial class IsNumneric : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void Button1_Click(object sender, EventArgs e)
        string strValue = TextBox1.Text;
        if (!Information.IsNumeric(strValue))
            Label1.Text = "Is Not Numeric";
            Label1.Text = "Numeric";

Next Post Previous Post
No Comment
Add Comment
comment url