In this article we will examine in particular how the new support for functional programming techniques in .NET 3.5 can help you do the following:
- Make your code more declarative.
- Reduce errors in code.
- Write fewer lines of code for many common tasks.
The Language Integrated Query (LINQ) feature in all of its many incarnations is an obvious and powerful use of functional programming in .NET, but that’s just the tip of the iceberg.
For more visit Functional Programming for Everyday .NET Development
For value types, “==” and Equals() works same way : Compare two objects by VALUE
int i = 5;
int k= 5;
i == k > True
i.Equals(k) > True
For reference types, both works differently :
“==” compares REFERENCE – returns true if and only if both references point to the SAME object.
Equals method compares object by VALUE.
StringBuilder sb1 = new StringBuilder(”Mahesh”);
StringBuilder sb2 = new StringBuilder(”Mahesh”);
sb1 == sb2 > False
sb1.Equals(sb2) > True
String s1 = “zzz”;
String s2 = “zzz”;
In above case the results will be,
s1 == s2 > True
s1.Equals(s2) > True
Why? Does that mean String a Value Type?
No, String IS a Reference Type. Although string is a reference type, the equality operators (== and !=) are defined to compare the values of string objects, not references. This makes testing for string equality more intuitive. For example:
- String: Contains, Count, Cut, EndsWith, Equals, IndexOf, InitCap, Join, LastIndexOf, Newline, NthIndexOf, PadLeft, PadRight, Split, SplitIntoFields, StartsWith, Trim, WordWrap
- RegEx: IsMatch, Matches, Match, MatchLength, MatchSimple, Replace, Split
- Math: CompoundAmortizationSchedule, Constant (30 physics constants), Convert (22 measurement conversions), Cosh, Factorial, IsPrime, RandomRange, Sinh, Tanh
- Date: BusinessDays, DaysInMonth, DaysLeftInYear, FirstDayOfMonth, FormatTimeSpan, FromUNIXTime, FullDateString, FullTimeString, IsBusinessDay, IsLeapYear, LastDayOfMonth, ToUNIXTime
- InterNet (not available in free version): AddressToNumber, FtpDo, FtpGet, FtpPut, GetHostName, GetIPAddress, GetWebPages, IsValidIPAddress, NumberToAddress, Ping, PingTime
- File (not available in free version): ChangeEncoding, Copy, CopyMultiple, CreateDirectory, Decrypt, Delete, DeleteDirectory, DeleteMultiple, Encrypt, GetDirectoryListing, GetDriveInfo, GetFile, GetFileBinary, GetRandomFileName, GetTempPath, GUnzip, GZip, Move, MoveMultiple, PathExists, SplitIntoFields, WriteFile, WriteFileBinary
- Miscellaneous: CRC32, Deflate, GenerateDateTimeRange, GenerateDateTimes, GenerateFloatRange, GenerateFloats, GenerateIntRange, GenerateInts, GUnzip, GZip, Hash, Inflate, IsValidCC, IsValidSSN, ToWords
- Database: DumpData (not available in free version)
- Convert: BinaryToHexString, FromBase64, HexStringToBinary, ROT13, ToBase64
- LookUps: GetCountryInfo, GetStateInfo
- Internal: Version, Help, Setup, Uninstall, GrantPermissions, IsUpdateAvailable, Update (not available in free version), SetSecurity, WebSite
- User-Defined Aggregates: GeometricAvg, Join, Median, Random, RootMeanSqr
- User-Defined Types: FloatArray, HashTable, NVarcharArray
What can SQL# do?
- SQL# gives you the easiest access to the power of the CLR!
– a single assembly with over 100 functions, 5 User-Defined Aggregates, 3 User-Defined Types, and more being added!
- SQL# installs easily and in moments!
– download one small install sql script, execute it, and enjoy the power of the CLR!
- SQL# is backed up and restored with the database along with all other objects and data!
– no need to worry about separate DLLs as with COM Extended Stored Procedures
- SQL# has built in documentation (list of function and procedure signatures)!
– if you ever lose the documention, the worst off you are is one procedure call away from viewing the entire list of function signatures!
- SQL# can easily be updated via the web in moments!
– you can optionally install updates via the web with a single procedure call
- SQL# saves countless hours learning CLR and .Net, not to mention the cost of Visual Studio 2005!
– time is money and you have work to do so why stop and learn yet another language, especially when you might need to purchase additional software just to compile a basic function!
- SQL# lets you focus on SQL programming without sacrificing the power of the CLR!
– again, there is only so much time in the day so do you want to spend it NOT being productive?
Download Free Version of SQL# (SQLsharp) here!
The manual and “What’s New” document cover both Free and Paid-For versions.
Manual in PDF format (766k)
What’s New in Version 2.5.20/2.5.21 (122k)
Date_BusinessDays ExcludeDaysMask Worksheet .
Download Spreadsheet (19k)
Via SQL# (SQLsharp) – Enabling more powerful SQL (Features)
In .NET 2.0+ and with the help of Visual Studio Generated Settings.settings, you can do the following:
Load your settings programmatically:
Settings set = Settings.Default;
Read from your settings:
string str = set.testSetting;
Write to your settings:
set.testSetting = “xyz”;
What’s New in C#
Community Web Sites and Downloads
Source from : Charlie Calvert’s Community Blog
del.icio.us Tags: LINQ