Posts

Difference between array, arraylist, List, Hashtable, Dictionary and SortedList in c#

Basic difference is that arrays are of fixed size. Whereas an ArrayList implements the list data structure and can dynamically grow. While arrays would be more performance that a list, a list would be far more flexible since you don't need to know the required size initially. Array - represents an old-school memory array - kind of like a alias for a normal type[] array. Can enumerate. Can't grow automatically. I would assume very fast insertion, retrieve and speed. ArrayList - automatically growing array. Adds more overhead. Can enum., probably slower than a normal array but still pretty fast. These are used a lot in .NET List - one of my favorites - can be used with generics, so you can have a strongly typed array, e.g. List . Other than that, acts very much like ArrayList. Hashtable - plain old hashtable. O(1) to O(n) worst case. Can enumerate the value and keys properties, and do key/val pairs. Dictionary - same as above only strongly typed via generics, such a...

Difference between IEnumerable VS IQueryable in c#

In LINQ to query data from database and collections, we use IEnumerable and IQueryable for data manipulation. IEnumerable is inherited by IQueryable, Hence IQueryable has all the features of IEnumerable and except this, it has its own features. Both have its own importance to query data and data manipulation. Let’s see both the features and take the advantage of both the features to boost your LINQ Query performance. IEnumerable IEnumerable exists in System.Collections Namespace. IEnumerable can move forward only over a collection, it can’t move backward and between the items. IEnumerable is best to query data from in-memory collections like List, Array etc. While query data from database, IEnumerable execute select query on server side, load data in-memory on client side and then filter data. IEnumerable is suitable for LINQ to Object and LINQ to XML queries. IEnumerable supports deferred execution. IEnumerable doesn’t supports custom query. IEnumerable doesn’t support lazy loading. H...

Difference between DataTable.Copy() Vs. DataTable.Clone() in C#

Image
Two major methods of DataTable in C#, One is Copy() and the other one is Clone() . Though these two sound identical but there are huge differences between these two. There are two things to copy or clone of a DataTable . These are structure and data . Copy and Clone are playing with these two. Let us create a DataTable first. DataTable dt = new DataTable(); dt.Columns.Add( " Id" ); dt.Columns.Add( " Name" ); dt.Columns.Add( " Email" ); dt.TableName = " MasterTable" ; // insert into DataTable dt.Rows.Add( " 1" , " Arka" , " arka@gmail.com" ); dt.Rows.Add( " 2" , " Anusua" , " anu@gmail.com" ); dt.Rows.Add( " 3" , " Sayantani" , " sayantani@gmail.com" );     DataTable.Copy() returns a DataTable with the structure and data of the DataTable . // Creating another DataTable to copy DataTable dt_copy = new DataTable(); dt.TableName = " CopyTable...

ASP.NET 4.0 potentially dangerous Request.Form value was detected issue resolved

To resolve the issue of request validation, I added the following to the existing "page" directive in that .aspx file. ValidateRequest="false" But I still got the same error. Later I found that, for .NET 4, we need to add requestValidationMode="2.0" to the httpRuntime configuration section of the web.config file like the following: <httpRuntime requestValidationMode="2.0"/> But if there is no httpRuntime section in the web.config file, then this goes inside the <system.web> section. If anyone wants to turn off request validation globally for a user, the following line in the web.config file within <system.web> section will help: <pages validateRequest="false" />  Note: But always avoid the last example because there is a huge security issue. The request validation feature in ASP.NET provides a certain level of default protection against cross-site scripting (XSS) attacks. However, we recommend that you analyze an...

All about Angular UI Bootstrap framework

Angular UI Bootstrap AngularUI Bootstrap, as name says, is built on top one of the most popular front-end frameworks, Bootstrap. The goal is to provide native AngularJS directives without any dependency on jQuery or Bootstrap's JavaScript. It is often better to rewrite an existing JavaScript code and create a new, pure AngularJS directive. Most of the time the resulting directive is smaller as compared to the original JavaScript code size and better integrated into the AngularJS ecosystem. Installation Installation is easy as UI Bootstrap has minimal dependencies - only the AngularJS and Twitter Bootstrap's CSS are required. Notes: •Sincer version 0.13.0, UI Bootstrap depends on ngAnimate for transitions and animations, such as the accordion, carousel, etc. Include  ngAnimate  in the module dependencies for your app in order to enable animation. •UI Bootstrap depends on ngTouch for swipe actions. Include  ngTouch  in the module dependencies for your app in order to e...

Mobile Angular UI framework

Mobile Angular UI is a mobile UI framework just like Sencha Touch or jQuery Mobile. Mobile Angular UI provides essential mobile components that are missing in Bootstrap 3: switches, overlays, sidebars, scrollable areas, absolute positioned top and bottom navbars that don't bounce on scroll.It relies on robust libraries like fastclick.js and overthrow.js to achieve the better mobile experience. Mobile Angular UI retains most of the Bootstrap 3 syntax. This way it's trivial to bring an existing desktop web app to mobile. Also a super-small css file is provided to do the opposite. Just include it and you'll get a fully responsive and touch enabled interface that can be used everywhere. Awesome Mobile Components Mobile Angular UI provides essential mobile components that are missing in Bootstrap 3: switches, overlays, sidebars, scrollable areas, absolute positioned top and bottom navbars that don't bounce on scroll. It relies on robust libraries like fastclick.js and overth...

All about AngularJs framework

Image
"AngularJS is a JavaScript framework which simplifies binding JavaScript objects with HTML UI elements." Let us try to understand the above definition with simple sample code. Below is a simple "Customer" function with "CustomerName" property. We have also created an object called as "Cust" which is of "Customer" class type. function Customer() { this.CustomerName = "AngularInterview"; } var Cust = new Customer(); Now let us say the above customer object we want to bind to a HTML text box called as "TxtCustomerName". In other words when we change something in the HTML text box the customer object should get updated and when something is changed internally in the customer object the UI should get updated. <input type=text id="TxtCustomerName" onchange="UitoObject()"/> So in order to achieve this communication between UI to object developers end up writing functions as shown below. "UitoO...