Free TechForWorld .Net Library: Collection of Useful .Net Functions

4 Flares Twitter 1 Facebook 0 Google+ 3 Filament.io 4 Flares ×

Here is a gift to .Net Application Programmers: A huge collection of useful .Net functions which you will find useful and interesting in your daily .Net programming. The project is written in C#.Net, and still being updated. Let me know if you have any question or suggestions, I would be glad to help you.
Techforworld-.net-library
Here are the usage guide-lines for some important classes and functions of the library:

1. DataMethods Class

DataMethods class provides all core functionality for SQL database.

Only once, you just need to provide the database connection string at the start up of your application.

TechForWorldLib.DataMethods.ConnectionString = “Data Source=TECHFORWORLDPC1;Initial Catalog=TechForWorld;User ID=sa;Password=sa@123”;

Or if you are using configuration file (App.config or Web.config):

TechForWorldLib.DataMethods.ConnectionString = ConfigurationManager.ConnectionStrings[“ConnectionString”];

Some of the important functions form this class:

  • GetDataSet
  • GetDataTable
  • GetDataRow
  • GetScalar
  • GetCount
  • ExecuteQuery: Execute non-query types like Insert, Update or Delete.
  • SearchEntireDatabase: Search for a string in all tables of the database

You can also use SQL transaction very easily with this class: Just call your all queries after calling BeginTrans: Use  RollBackTrans to cancel (undo) the transaction and use CommitTrans at last on success.
DataMethods class is used for all database related operations by other classes of the library too- like DataExporter class.

2. StringMethods Class

All methods related to string which you are missing in C#.Net.

  • IsNumeric: Check if the provided text is a numeric value or not
  • Split
  • IsStringEmpty: Check if the string is null or empty with trimming spaces
  • GenerateRandomString
  • GetRandomNumber
  • ToSentenceCase: Convert the text to proper sentence case
  • ChopText
  • ReplicateString
  • NumberToWords:  Convert a numeric value into word format.

3. FileHandling Class

Offers functions related to writing in files and getting file information. Important functions:

  • GetFileName: Get a file name from the full path
  • GetDirectoryPath: Get directory path of the file
  • IsDirectory: Check if the given path is a directory or a file
  • CopyFiles: Copy or move files from given sources to the destination

4. MediaPlayer Class

Easily play background sound using methods of this class. Offers Play, Pause, Stop and functions to control volume, treble and bass.

MediaPlayer objPlayer = new MediaPlayer();
bool Loop = true;
objPlayer.Play(“D:\Media\Sounds\Tone1.mp3”, Loop);

5. Calculator Class

Provide any simple or complex input formula and this class will evaluate it and give you the result. The function automatically handles parenthesis.

Double result = Convert.ToDouble(Calculator.Calculate(“2448+38483*133)-3823/424+284”));

6. DataExporter Class

Export data from your data table or from SQL Select query to a file in formats like plain text, HTML and CSV (Excel).

objExporter = new DataExporter();
objExporter.DataTable = dt1;
objExporter.TableTitle = “Daily Report”;
objExporter.ExportHTML(“D:\Reports\Report1.html”);
objExporter.ExportPlainText(“D:\Reports\Report1.txt”);
objExporter.ExportCSVFormat(“D:\Reports\Report1.csv”, “,”);

7. DateDifference Class

Easily find difference between two dates in year, month and days.

DateDifference objDateDiff = new DateDifference(DateTime.Now, New DateTime(1982, 9, 28));
string difference = objDateDiff.ToString();

8. DateTimeMethods Class

Functions related to date-time like convert a string to usable date, get month number from month name or month short-name, convert a date into word format.

  • ConvertToSystemDate (“09/28/1982”, “M/d/yyyy”)
  • GetMonthNumberFromMonthName (“JAN”)
  • GetDateInWords

9. HTMLUtil Class

Easily generate HTML formatted text and save to a file. You can provide a DataTable and automatically convert it into HTML format.

HTMLUtil objHTML = new HTMLUtil();
objHTML.FilePath = Application.StartupPath + “\\” + “Contacts.html”;
objHTML.AddText(“Contacts”, “bold”, null, “underline”, null, null, null, HTMLUtil.Align.Center);
objHTML.AddTable(dtContacts, “Name|Phone1|Phone2”, “Name|Phone 1|Phone 2”, “200px|100px|100px”);
objHTML.Print();

10. Networking Class

Useful networking related methods like check if a website is running or down, check if internet connection is available or not.

  • CheckInternetConnection (“http://techforworld.com”)

Conclusion

You may download the TechForWorld .Net Library here. The source code of the library is available on limited basis, contact/email us for it.

4 Flares Twitter 1 Facebook 0 Google+ 3 Filament.io 4 Flares ×

Comments

  1. says

    Very impressive language and words are used on the page. This is the best way of representing a topic. Easy language and words are used+they are very easy to understand. I will share this website and information given in it.

Leave a Reply

Your email address will not be published. Required fields are marked *