background preloader

LINQ

Facebook Twitter

How to do CreateFileMapping in a C++ DLL and access it in C#, VB and C++ Download source code - 1.33 MB Introduction This is a sample of how to use a shared memory in SetData/GetData pattern like a map.

How to do CreateFileMapping in a C++ DLL and access it in C#, VB and C++

Hide Copy Code. Compiling C# Code at Runtime. Download source - 1.3 KB Introduction Sometimes, it is very useful to compile code at runtime.

Compiling C# Code at Runtime

Personally, I use this feature mostly in these two cases: Set 8 (Matrix Chain Multiplication) Given a sequence of matrices, find the most efficient way to multiply these matrices together.

Set 8 (Matrix Chain Multiplication)

The problem is not actually to perform the multiplications, but merely to decide in which order to perform the multiplications. We have many options to multiply a chain of matrices because matrix multiplication is associative. LINQ를 통한 데이터 변환(C#) [WPF/Silverlight] 동적으로 스타일 지정하기. LINQ to XML in a Nutshell. Data may exist in many forms.

LINQ to XML in a Nutshell

You may have data in relational tables residing on a relational database or portable data in the form of XML. Since data exists in many forms, obviously there are many ways to manipulate or access it. One of the most popular ways of sharing data is as XML. Considering the prominent presence of XML as way of data sharing, LINQ to XML got introduced in C# 3.0 to work effectively and efficiently with XML data.

The LINQ to XML API contains classes to work with XML. LINQ to XML to retrieve an element value by its attribute. Introduction This article tells us how to retrieve a value of an element depending on the attribute value.

LINQ to XML to retrieve an element value by its attribute

The Scenario I have a web site where I need to read some data as static but I want to be able to update it any time, so I decided to read it from an XML file and use LINQ to XML. After some time and a lot of searching here and there, I had a better understanding of the idea and so I decided to share it with every one.

Using the Code. XML Elements vs. Attributes. Convert XML to Object using LINQ. Introduction.

Convert XML to Object using LINQ

iGoogle. 마이크로소프트웨어. 읽을거리 > 디벨로퍼 플러스 Entity Framework를 사용하는 경우가 늘어나면서 linq를 쓰게 되고, 덕분에 알게 모르게 람다(lambda)를 많이 사용하게 됐다.

마이크로소프트웨어

알고보면 람다는 linq 외에도 여러모로 쓸모가 많다. 그 동안 별 생각없이 람다를 써왔다면 이번 기회에 제대로 알고 써보도록 하자. 차영호 andrew.chaa@yahoo.co.uk|Totaljobs.com 이라는 인터넷 회사에서 닷넷 웹 개발자로 있다. 책읽기를 좋아하고 여러가지 배우는 것을 좋아한다. 람다의 발견 람다는 어느새 우리 곁에 깊숙히 들어와 있다. <그림 1> 비주얼 스튜디오에서 Where 메소드에 들어가는 인자들 <그림 1>에서 비주얼 스튜디오가 Where() 메소드의 인자인 Func<TSource, bool> predicate을 보여주고 있다. <리스트 1>은 흔히 사용되는 코드다. 람다는 =>를 기준으로 왼쪽(x)과 오른쪽(x == “me”)으로 나눠진다. Func <string, bool> predicate Func에 string, bool의 타입이 표시되어 있는데 이는 string을 인자(parameter)로 받고 bool 타입을 리턴하는 것을 뜻한다. <리스트 2>는 Func를 이용해 만든 메소드다. 참고로 Func는 리턴값이 있을 때 사용한다. 왜 사람들이 람다를 쓸까? 람다의 간결성 그 이유는 다음과 같다. 참고로 필자가 거주중인 영국에서 => 표시는 영어로는 “goes to”, “maps to”, “becomes” 등으로 읽는다(필자의 주변에는 한국인 개발자가 없어서 우리말로는 어떻게 표현되는지 잘 모르겠다.

메소드들 간의 유기적 결합 두 번째 이유는 람다 표현식을 인자로 받음으로서 여러개의 메소드를 서로 결합해 복합적인 상승효과를 낼 수 있다는 데 있다. Count()라는 단순한 함수이지만 n => n &2 == 1 이라는 람다식을 이용해 홀수들만의 갯수를 구할 수 있다. 101 LINQ Samples in C# A Primer on LINQ and Lambda. Jeremy Foster I still remember the day well.

A Primer on LINQ and Lambda

I had heard a ton of buzz about LINQ statements and lambda expressions, so I knew they were pretty big deals, but I didn’t have the concept. I didn’t know why they were important or when. In short, I didn’t know what problem they solved. I looked all over the internet for a good description of the why/when… for the problem statement… for the concept, but I didn’t really find it.

Download LINQPad. LINQ Examples: System.Linq and Extensions. Array Class Collections File Keyword String .NET ASP.NET Cast Compression Data Delegate Directive Enum Exception If Interface LINQ Loop Method Number Process Property Regex Sort StringBuilder Struct Switch Time Windows WPF Imperative code describes how to complete an algorithm step-by-step.

LINQ Examples: System.Linq and Extensions

Declarative code instead describes the end result of that algorithm. LINQ is a declarative syntax form. It makes some computational tasks easier. Intro LINQ (language integrated query) introduces extension methods. Example:We use the Average extension method to average all the elements in an int array. Tip:The Average method is implemented as an extension method within the .NET Framework. Extension Method Based on: .NET 4.5 Program that uses LINQ extension: C# using System; using System.Linq; class Program { static void Main() { int[] array = { 1, 3, 5, 7 }; Console.WriteLine(array.Average()); } } Output 4 Convert ToArrayToDictionaryToListToLookup Mutate Skip, SkipWhileTake, TakeWhile Computation Max, Min Var.

C# .NET Autoupdate Application Launcher. Download source code - 217 KB Introduction When we develop web-based solutions, usually, we are in charge of updating the installations to use a current version.

C# .NET Autoupdate Application Launcher

We fix some bugs, add a feature, make a patch, and deploy it so that our customers can continue using our software without interruption. But when we have clients installing our software, we still need to give them updates. C#/.NET Little Wonders: Select() and Where() with Indexes. Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain.

The index of all my past little wonders posts can be found here. We’ve talked about the Select() and Where() LINQ extension methods before. The Select() method lets you project from the source type to a new type, and the Where() method lets you filter the list of items to the ones you are interested in. Most people know of these methods in their simplest form, where they simply take a projection and predicate respectively that operates on just an element. LINQ to XML 개요. Convert a List<> Into XML using LINQ. Convert a List<> Into XML using LINQ In this article, I will demonstrate a simple example of converting a List<> to XML using LINQ. I assume that you are familiar with LINQ to XML. If that is not the case, I would recommend you to get some hands-on on LINQ to XML. These three articles will help out out: