Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for the ‘C#’ Category

VS 2010 Webinar Session Overviews

Visual Studio 2010 is set to be released in April.  Microsoft has made significant investments to improve the “Testing”, “Architecture”, and “Developer” tools within Visual Studio to make it an even more powerful productivity solution.

VS 2010 Webinar Session Overviews:

TITLE DESCRIPTION
Full Testing Experience: Professional QA with Visual Studio 2010 Join us as we demonstrate the testing and quality assurance lifecycle using Visual Studio 2010 and Team Foundation Server. We’ll dive into the testing tools and testing process you can use to dramatically improve the effectiveness of your QA and Test efforts. You’ll see the Microsoft Test and Lab Manager (MTLM) in all its glory as we explore how to manage your test environment, organize test suites, test cases, requirements and bugs, and how to manage both automated and manual test runs. In addition, you’ll see how to easily create an automated test from an existing manual test run. Finally, and most importantly, you’ll discover how insanely easy it is to create bugs that can be simply and reliably reproduced by developers – VS 2010 is that powerful.
Improving Development Practices with  Visual Studio 2010 This is an overview of the new development and database tools in Visual Studio 2010. New capabilities of historical debugging, code analysis, profiling and the new test impact analysis will be demonstrated. Working with Team Foundation Server (TFS) 2010, gated-check-in will be discussed as well as the tester/developer collaboration experience. The new architect tools will be demonstrated to facilitate a better understanding of how modeling is a part of the development experience.
Lab Manager – The Ultimate “No More No Repro” Tool Designing, building and testing code is a hard job. A job made even harder by the fact that most organizations don’t have development and test environments that are clean, easily reset and similar to the production environment. Enter virtualization…and Lab Manager. Lab manager allows you to define, configure and create complete development or test environments as needed. It can coordinate both physical and virtual environments, and comes with an incredibly powerful suite of effective tools that make managing environments simple and cost effective. Attend this webcast event to see Lab Manager in action!
Managing Requirements with Team Foundation Server 2010 Requirements management is a struggle for many organizations. A distinction must be drawn between requirements elicitation, requirements documentation and requirements management. Team Foundation Server provides rich capabilities for managing requirements and can easily be integrated with your preferred tools for documenting requirements. Best practices of requirement elicitation, documentation, management and traceability will be discussed in the context of the requirement lifecycle and how TFS 2010 and third party tools can maximize your overall requirements management process.
Overview of Visual Studio 2010 ALM Tools This overview of Visual Studio 2010 highlights the difference between Team System 2008 and Visual Studio 2010. Emphasis will be put on what migration steps need to be taken to maximize new features including testing tools, version control, work item tracking and build enhancements. As a basis for demonstration, the development processes and practices used to create Notion Tools for Team System will be shown, including branching models, build and deployment automation, custom reporting and workflows.
Streamlining Testing with  Visual Studio 2010 ALM Tools This Visual Studio 2010 overview features Visual Studio Test Elements 2010 testing tools including using the new Microsoft Test and Lab Manager to manage and automate your UI testing. The use of Test Lab will be discussed as a means of automating the creation of virtual environments for testing purposes. Deploying to VM environments during build will be demonstrated and facilitate a robust developer/tester lifecycle. For a taste of real-world use, the test plans and test process used to perform multi-platform testing of Notion Tools for Team System will be shown.
Using Team Foundation Server 2010 for Non-Windows Development This is an overview of best practices for utilizing Team Foundation Server (TFS) 2010 and the Teamprise Client Suite for development activities beyond Microsoft and the Windows platform. This webcast shows development teams using mixed and non-Microsoft platforms how to effectively leverage TFS 2010 to adopt work item tracking, version control, and automated build and test technologies.
Visual Studio 2010 Quality Tools for Developers This webcast event will demonstrate how developers use Visual Studio 2010 and Team Foundation Server to create high quality code, reliably reproduce and efficiently fix reported bugs, and truly work with the testing team. We’ll demonstrate the use of several important tools, such as test impact analysis, IntelliTrace, and other tools that help you understand your code, pinpoint bugs and efficiently fix them. Let’s face it – fixing bugs is both tedious and hard. VS 2010 provides the tools to both you and the tester to make finding, reproducing and fixing bugs dramatically simpler.
What’s New in Visual Studio 2010 Why you should consider Visual Studio and Team Foundation Server 2010. We’re going to discuss the specific business value of the Visual Studio ALM tools now and later. Free webinar event to learn how to get the most out of the Visual Studio investments that your organization has made. You owe it to yourself to learn how this new solution will help you be a more productive in your role!
  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

C# Code Snippet: Finding a Node in an XML String

XML to be operated on:

   1: <States>

   2:   <State name="Wisconsin">

   3:     <Regions>

   4:       <Region name="Milwaukee">

   5:         <Area name="Mukwanago"/>

   6:         <Area name="Germantown"/>

   7:       </Region>

   8:       <Region name="Fox Valley">

   9:         <Area name="Oshkosh" />

  10:         <Area name="Appleton" />

  11:       </Region>    

  12:     </Regions>

  13:   </State>

  14: </States>

C# code:

   1: // using System.Xml.Linq

   2:  

   3: // make sure the xml file exists

   4: XElement states  = XElement.Load("testXML.xml");

   5:  

   6: // Using LINQ

   7: XElement foundNode;

   8: var query = from XElement r in states.Descendants("Region")

   9:                    where r.Attribute("name").Value == "Milwaukee"

  10:                    select r;

  11: foundNode = query.FirstOrDefault();

  12:  

  13: // Using Lambda expressions

  14: foundNode = states.Descendants("Region").

  15:      Where(r => r.Attribute("name").Value ==

  16:                          "Milwaukee").FirstOrDefault(); 

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

Visual Studio Team Foundation Server 2010 Upgrade Guidance

The guide covers scenarios which may be encountered during and after the upgrade process. It provides examples of most common and potential issues. It covers scenarios related to general Upgrade Process, Work Item Templates, Reports, and Enterprise TFS Management (ETM). Although this guide refers to TFS 2008 scenarios, almost all the concepts apply also to TFS 2005.

Visual Studio ALM Rangers

This guidance is created by the Rangers who have the mission to provide out of band solutions for missing features or guidance. This content was created with support from Microsoft Product Group, Microsoft Most Valued Professionals (MVPs) and technical specialists from technology communities around the globe, giving you a real-world view from the field, where the technology has been tested and used.

What is in the package?
The download package consist of three seperate ZIP files containing a number of quick reference posters and quick reference sheets in XML Paper Specification (XPS) format:

  • Visual Studio 2010 Quick Reference Guidance – Overview (Default Download)
    • An overview of the guidance and focus areas, contained in one index table and overview quick reference poster.
  • Visual Studio 2010 Quick Reference Guidance – Basic Guidance
    • A collection of basic guidance sheets, focusing on the “what” are the key features and “why” to consider them.
  • Visual Studio 2010 Quick Reference Guidance – Supporting Guidance
    • A set of documents and quick reference posters, supporting the basic guidance sheets.

A single document with the seven upgrade scenarios, upgrade related questions and answers. Download your copy today!

Go http://vs2010upgradeguide.codeplex.com 

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

C# Code Snippet: List.ForEach method

Do you ever use the List(T).ForEach Method in C#, if never, you’d better read this.

The syntax is :
public void ForEach(Action<T> action)

   1: static void Main()

   2: {

   3:     List<long> myList = new List<long>();

   4:     foreach (string item in "269, 361, 347, 355, 352, 346, 351, 354".Split(','))

   5:     {

   6:         myList.Add(long.Parse(item.Trim()));

   7:     }

   8:     myList.ForEach(FA);

   9: }

  10:  

  11: static void FA(long num)

  12: {

  13:     Console.WriteLine(num);

  14: }

Is that cool? It gives lots of convenience in coding!

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

List(T).BinarySearch in C#

I think most of us are quite familiar with binary search. Binary search is an algorithm for locating the position of an element in a sorted list by checking the middle, eliminating half of the list from consideration, and then performing the search on the remaining half.If the middle element is equal to the sought value, then the position has been found; otherwise, the upper half or lower half is chosen for search based on whether the element is greater than or less than the middle element. The method reduces the number of elements needed to be checked by a factor of two each time, and finds the target value, if it exists in logarithmic time. A binary search is a dichotomy divide and conquer search algorithm.

In C#, .Net provide a List<T>.BinarySearch Method (T) which can be used easily. here is a demo:

   1: // Init a long type list

   2: var myList = new List<long>();

   3: foreach (var item in "269, 361, 347, 355, 352, 346, 351, 354".Split(','))

   4: {

   5:     myList.Add(long.Parse(item.Trim()));

   6: }

   7:  

   8: // sort

   9: myList.Sort();

  10: var ret = myList.BinarySearch(347);

  11: Console.WriteLine(ret);

Note, I have a ‘myList.Sort();’ before call the BinarySearch, why? It is because BinarySearch will Search the entire sorted System.Collections.Generic.List<T> for an element using the default comparer and returns the zero-based index of the element.

Yes, it is sorted list that binary search will operate on! So remember make your list sorted before call binary search function

  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark