Browsed by
Category: Programing

Detect pivot table in Microsoft Excel using Interop c#

Detect pivot table in Microsoft Excel using Interop c#

Here is some code for reference. Identify the overall Range occupied by PivotTables in the sheet and validate whether the cell is a part of the Range.

For refresh pivot table:

 

Property Design

Property Design

Although properties are technically very similar to methods, they are quite different in terms of their usage scenarios. They should be seen as smart fields. They have the calling syntax of fields, and the flexibility of methods. ✓ DO create get-only properties if the caller should not be able to change the value of the property. Keep in mind that if the type of the property is a mutable reference type, the property value can be changed even if the property…

Read More Read More

Data consistency in Rails: Understanding the different between transaction and locking

Data consistency in Rails: Understanding the different between transaction and locking

Source Tất cả bắt nguồn từ bài post này của bên Grokking VietNam. Đại ý của bài viết như sau: Một ứng dụng chuyển tiền của ngân hàng có một đoạn code như dưới đây:

Ứng dụng chạy một thời gian thì có bug là tài khoản của một vài người dùng bị âm tiền. Vấn đề ở đây là gì và cách giải quyết. Mới đầu khi đọc bài viết tôi cũng thấy hơi khó hiểu khi đoạn code trên về…

Read More Read More

Export Crystal Reports to PDF in C#

Export Crystal Reports to PDF in C#

Source: https://www.c-sharpcorner.com/UploadFile/26b237/export-crystal-report-to-pdf-in-C-Sharp/ When you want to export your Crystal Reports report to PDF format or any other format, this article provides guidance for exporting the Crystal Reports report to PDF format. In this we can use ExportOptions for exporting the Crystal Reports report to PDF format. In the following example you can see how to export a Crystal Reports report as a PDF format file in C#. If you read my first article then it’s easy to understand this example, if…

Read More Read More

C# type

C# type

C# Type .Net Framework (System) type Signed? Bytes Occupied Possible Values sbyte System.Sbyte Yes 1 -128 to 127 short System.Int16 Yes 2 -32768 to 32767 int System.Int32 Yes 4 -2147483648 to 2147483647 long System.Int64 Yes 8 -9223372036854775808 to 9223372036854775807 byte System.Byte No 1 0 to 255 ushort System.Uint16 No 2 0 to 65535 uint System.UInt32 No 4 0 to 4294967295 ulong System.Uint64 No 8 0 to 18446744073709551615 float System.Single Yes 4 Approximately ±1.5 x 10-45 to ±3.4 x 1038 with 7 significant…

Read More Read More

How to: Upload Files with FTP

How to: Upload Files with FTP

This sample shows how to upload a file to an FTP server. Example C#

Compiling the Code

What’s the main difference between int.Parse() and Convert.ToInt32

What’s the main difference between int.Parse() and Convert.ToInt32

If you’ve got a string, and you expect it to always be an integer (say, if some web service is handing you an integer in string format), you’d use Int32.Parse(). If you’re collecting input from a user, you’d generally use Int32.TryParse(), since it allows you more fine-grained control over the situation when the user enters invalid input. Convert.ToInt32() takes an object as its argument. (See Chris S’s answer for how it works) Convert.ToInt32() also does not throw ArgumentNullException when its argument is null the way Int32.Parse() does. That…

Read More Read More

C# Coding Standards and Naming Conventions

C# Coding Standards and Naming Conventions

Below are our C# coding standards, naming conventions, and best practices. Use these in your own projects and/or adjust these to your own needs.   douse PascalCasing for class names and method names. public class ClientActivity { public void ClearStatistics() { //… } public void CalculateStatistics() { //… } } Why: consistent with the Microsoft’s .NET Framework and easy to read. douse camelCasing for method arguments and local variables. public class UserLog { public void Add(LogEvent logEvent) { int itemCount = logEvent.Items.Count; // … }…

Read More Read More

C# Iterate through Class properties

C# Iterate through Class properties

You could possibly use Reflection to do this. As far as I understand it, you could enumerate the properties of your class and set the values. You would have to try this out and make sure you understand the order of the properties though. Refer to this MSDN Documentation for more information on this approach. For a hint, you could possibly do something like:

Where value is the value you’re wanting to write in (so from your resultItems array).

C#: Favorite Features through the Years

C#: Favorite Features through the Years

Abstract: Each newer version of C# is packed full of powerful and impactful features. In this tutorial I walk through the various versions of C# and share my favorite features from each release.  516    59    68 Anytime I get the chance to write about C#, I’m eager to do so. This time was no System.Exception! As of this writing, C# has been around for over 17 years now, and it is safe to say it’s not going anywhere. The…

Read More Read More