.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Code files in the C#.net

Posted By: Narayanan     Posted Date: March 20, 2012    Points:5   Category :C#
Hi friends,
How to use of Code File in the C#.net?Can you give me an Some example for Code file creation and Call a Code file in the Application? Thanks in Advanced.

Author: Pawan Awasthi             
Posted Date: March 24, 2012     Points: 20   

Hai Narayan,

Code files are those files which are separate files and used in some other files. These files mainly used as the common files and used in class files.
You can refer the below code snippet where i have created a Common.cs file and it contains the method:
using System;
using System.Data;
using System.Data.OleDb;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Office.Interop.Excel;

// Common.cs
// This file is the code for common static methods to use throughout the application.
// Modification Control Log
// Date By Version Description
// 01/11/2012 PA 1.0 common static methods to use throughout the application
// 01/16/2012 PA 1.1 added new method toe clear all the controls of the page

namespace SCPApp.Utilities
public static class Common
public static bool isValid = false;
/// <summary>
/// Common method to get the Max ID
/// </summary>
/// <param name="strQuery"></param>
/// <returns></returns>
#region Validation Methods

public static bool isDate(string inputDate)
string strDate = null;
strDate = Convert.ToString(DateTime.Parse(inputDate));
bool strRegex = false;
strRegex = System.Text.RegularExpressions.Regex.IsMatch(inputDate, "^([0-9]{1,2})[./-]+([0-9]{1,2})[./-]+([0-9]{2}|[0-9]{4})$");
if ((strRegex == false)) return (false);
else return (true);

return (false);

Here to call the methods of this code class, you need to first add the namespace of this file and then you can class its methods.
Hope it will help you. Let me know if need further clarifications.

Pawan Awasthi
(Whats App)+91 8123489140
(cell No.) +6 0143651476

Skype: Pawansoftit

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend