background preloader

Dot Net Perls: C#

Dot Net Perls: C#

String Enumerations in C# Introduction The idea of string enumerations in C# (and the lack thereof), has bothered me for a while. Enum's are useful things but only allow the storage of numeric types. What if you want to use strings? Background It struck me that I had a number of requirements when using string 'constants'. I wanted the ability to define the values in-line and reference them like an enum value - e.g. Options Constants The first thing I naturally gravitated towards was constants defined in a specific class. public sealed class MyConsts { private MyConsts() {} public const string Val1 = "MyVal1"; public const string Val2 = "MyVal2"; public const string Val3 = "MyVal3"; } The constants can be easily accessed as MyConsts.Val1 etc. Constants do have an interesting side effect in that the values are actually copied to any client code that uses the class. Static readonly readonly values can be initialized with a value and changed only within a class's constructor. Enums StringEnum Using the code Points of interest

Best Practices for Speeding Up Your Web Site The Exceptional Performance team has identified a number of best practices for making web pages fast. The list includes 35 best practices divided into 7 categories. Minimize HTTP Requests tag: content 80% of the end-user response time is spent on the front-end. One way to reduce the number of components in the page is to simplify the page's design. Combined files are a way to reduce the number of HTTP requests by combining all scripts into a single script, and similarly combining all CSS into a single stylesheet. CSS Sprites are the preferred method for reducing the number of image requests. Image maps combine multiple images into a single image. Inline images use the data: URL scheme to embed the image data in the actual page. Reducing the number of HTTP requests in your page is the place to start. top | discuss this rule Use a Content Delivery Network tag: server The user's proximity to your web server has an impact on response times. top | discuss this rule top | discuss this rule tag: css

C# Tutorials (C#) The C# tutorials provide an overview of the basics of the language and identify important language features. Each tutorial includes one or more sample programs. The tutorials discuss the sample code plus provide additional background information. See Also Математический подход к созданию сайтов «Математика прекрасна». Это может показаться абсурдным, для людей которые при одном только упоминании математики вздрагивают. Однако некоторые из самых красивых вещей в природе и нашей Вселенной — это проецирование математических свойств, от самых маленьких до крупнейших галактик. Один из древних философов, Аристотель сказал: «математическим наукам свойственно выстраивать все по порядку, в симметрии и ограничениях, они являются главными формами прекрасного». Из-за своей природной красоты, математика является частью искусства и архитектуры. Все рекомендации данные тут, так-же использовались в процессе написания этой статьи и ее примеров. Золотое сечение «и» Золотой прямоугольник Золотое сечение, также известное как божественная пропорция являет собой иррациональную математическую константу со значением примерно 1,618033987. Мы уже опубликовали очень подробную статью «Применение золотого сечения в web-дизайне», которая объясняет, как использовать золотое сечение в веб-дизайне. PSD-макет

NetOffice - MS Office in .NET Build a stylish image gallery using Lightbox 2 and JavaScript JavaScript is arguably the most ubiquitous programming language of the Web and is nearly as pervasive as HTML, XHTML, and CSS. There are a wealth of useful JavaScript libraries, too, and the best of these work on any modern browser, handling browser variances and user preferences uniformly. One of the most useful and popular JavaScript libraries is Lightbox 2, which provides online image gallery capabilities, image overlays, and navigation within sets (or groups) of images. Everyone's a photographer these days Five years ago, it seemed like everyone was blogging. With a few hundred bucks, even high school students can purchase a nice digital camera and begin building their photography skills. Enter Lightbox (and now its successor, Lightbox 2). Figure 1. As you'll soon learn, though, you can take Lightbox a lot further than this utilitarian setting. Before digging deeper into the specifics, there are a few good reasons to use Lightbox, and you should know each of them. Back to top <! <! <! <!

Delegates Tutorial (C#) This tutorial demonstrates the delegate types. It shows how to map delegates to static and instance methods, and how to combine them (multicast). Sample Files Further Reading Tutorial A delegate in C# is similar to a function pointer in C or C++. A delegate declaration defines a type that encapsulates a method with a particular set of arguments and return type. An interesting and useful property of a delegate is that it does not know or care about the class of the object that it references. Note Delegates run under the caller's security permissions, not the declarer's permissions. This tutorial includes two examples: Example 1 shows how to declare, instantiate, and call a delegate. In addition, it discusses the following topics: Delegates and Events Delegates vs. Example 1 The following example illustrates declaring, instantiating, and using a delegate. The use of delegates promotes good separation of functionality between the bookstore database and the client code. Output Code Discussion

Реализация простого видеочата на ASP.NET MVC Доброго времени суток, господа хабраюзеры! В данном топике я расскажу, как можно сделать простой видео-чат на ASP.NET MVC. Но для начала предыстория. Мы запускаем сервис видеоконсультаций с врачом через интернет. О нём обязательно будет отдельная статья, а сейчас хотим выяснить, насколько большую нагрузку смогут выдержать сервера и каналы. Пишется всё под ASP.NET MVC 4. Далее по пунктам. Реализация чата. Store здесь – статическая коллекция пользователей, которую при желании можно легко заменить на свою реализацию. На клиенте создаём соответствующие методы. Далее необходимо обеспечить функционал «звонков». Схема работы следующая: когда один абонент (допустим, Ангелина) хочет позвонить другому (к примеру, Пете), Ангелина вызывает метод Call и передаёт ему ключ Пети, свой ключ и своё имя. function OnAcceptCall(isMy, roomKey) { document.location = '@Url.Action("Room", "Home")' + '? На странице личного чата с помощью переданных ключей инициализируем флешку и текстовый чат.

How-To Program with Microsoft Office Excel and C# using a Ribbon and Interop In the previous example (How-To program with Excel and C#), I demonstrated how to program in Excel 2007 using a Workbook Project in Visual Studio 2008. This example will use the Addin Project in Visual Studio 2008 to create a ribbon that can be inserted into any Excel file automatically. Getting Started If you are familiar with VS2008, start by creating a Microsoft Office 2007 Excel Addin Project. If you are new to VS2008, start by creating a project. You can name your project anything you like. Add Form for Dialogbox In this step we are going to add a Windows Form to the project. Right-Click the Project in the Solution Explorer window, click Add->Windows Form. Once the form is created in the editor, I will add a TextBox, Label and Button from the Toolbox. Select the Textbox component and change the following properties in the Properties window: Microsoft.Office.Interop.Excel.Application excelObj; //Make sure it is active to load HW formthis.Activate ( ); //Hide the dialogbox this.Hide();

Related: