Archive for February, 2009


Convert integer to Enum instance

Example: Convert integer to Enum instance

public void EnumInstanceFromInt()
{
   // The .NET Framework contains an Enum called DayOfWeek.
   // Let's generate some Enum instances from int values.

   // Usually you wouldn't cast an instance of an existing Enum to an int
   // in order to create an Enum instance.  :-)   You would have the actual
   // integer value, perhaps a value from a database where the int value of
   // the enum was stored.

   DayOfWeek wednesday =
      (DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)DayOfWeek.Wednesday);
   DayOfWeek sunday =
      (DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)DayOfWeek.Sunday);
   DayOfWeek tgif =
      (DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)DayOfWeek.Friday);

   lblOutput.Text = wednesday.ToString()
      + ".  Int value = " + ((int)wednesday).ToString() + "";
   lblOutput.Text += sunday.ToString()
      + ".  Int value = " + ((int)sunday).ToString() + "";
   lblOutput.Text += tgif.ToString()
      + ".  Int value = " + ((int)tgif).ToString() + "";

The Enum.ToObject method takes two arguments. The first is the type of the
enum you want to create as output. The second field is the int to convert.
Obviously, there must be a corresponding Enum entry for the conversion to succeed.

Bond Basics: Different Types Of Bonds

Government Bonds

In general, fixed-income securities are classified according to the length of time before maturity. These are the three main categories:



Bills –
debt securities maturing in less than one year.

Notes - debt securities maturing in one to 10 years.

Bonds - debt securities maturing in more than 10 years.



Marketable securities from the U.S. government – known collectively as Treasuries – follow this guideline and are issued as Treasury bonds, Treasury notes and Treasury bills (T-bills). Technically speaking, T-bills aren’t bonds because of their short maturity. (You can read more about T-bills in our Money Market tutorial.) All debt issued by Uncle Sam is regarded as extremely safe, as is the debt of any stable country. The debt of many developing countries, however, does carry substantial risk. Like companies, countries can default on payments.



Municipal Bonds

Municipal bonds, known as “munis”, are the next progression in terms of risk. Cities don’t go bankrupt that often, but it can happen. The major advantage to munis is that the returns are free from federal tax. Furthermore, local governments will sometimes make their debt non-taxable for residents, thus making some municipal bonds completely tax free. Because of these tax savings, the yield on a muni is usually lower than that of a taxable bond. Depending on your personal situation, a muni can be a great investment on an after-tax basis.



Corporate Bonds

A company can issue bonds just as it can issue stock. Large corporations have a lot of flexibility as to how much debt they can issue: the limit is whatever the market will bear. Generally, a short-term corporate bond is less than five years; intermediate is five to 12 years, and long term is over 12 years.



Corporate bonds are characterized by higher yields because there is a higher risk of a company defaulting than a government. The upside is that they can also be the most rewarding fixed-income investments because of the risk the investor must take on. The company’s credit quality is very important: the higher the quality, the lower the interest rate the investor receives.



Other variations on corporate bonds include convertible bonds, which the holder can convert into stock, and callable bonds, which allow the company to redeem an issue prior to maturity.





Zero-Coupon Bonds

This is a type of bond that makes no coupon payments but instead is issued at a considerable discount to par value. For example, let’s say a zero-coupon bond with a $1,000 par value and 10 years to maturity is trading at $600; you’d be paying $600 today for a bond that will be worth $1,000 in 10 years.


Bond Basics: Characteristics

Bonds have a number of characteristics of which you need to be aware. All of these factors play a role in determining the value of a bond and the extent to which it fits in your portfolio.



Face Value/Par Value

The face value (also known as the par value or principal) is the amount of money a holder will get back once a bond matures. A newly issued bond usually sells at the par value. Corporate bonds normally have a par value of $1,000, but this amount can be much greater for government bonds.



What confuses many people is that the par value is not the price of the bond. A bond’s price fluctuates throughout its life in response to a number of variables (more on this later). When a bond trades at a price above the face value, it is said to be selling at a premium. When a bond sells below face value, it is said to be selling at a discount.



Coupon (The Interest Rate)

The coupon is the amount the bondholder will receive as interest payments. It’s called a “coupon” because sometimes there are physical coupons on the bond that you tear off and redeem for interest. However, this was more common in the past. Nowadays, records are more likely to be kept electronically.



As previously mentioned, most bonds pay interest every six months, but it’s possible for them to pay monthly, quarterly or annually. The coupon is expressed as a percentage of the par value. If a bond pays a coupon of 10% and its par value is $1,000, then it’ll pay $100 of interest a year. A rate that stays as a fixed percentage of the par value like this is a fixed-rate bond. Another possibility is an adjustable interest payment, known as a floating-rate bond. In this case the interest rate is tied to market rates through an index, such as the rate on Treasury bills.



You might think investors will pay more for a high coupon than for a low coupon. All things being equal, a lower coupon means that the price of the bond will fluctuate more.



Maturity

The maturity date is the date in the future on which the investor’s principal will be repaid. Maturities can range from as little as one day to as long as 30 years (though terms of 100 years have been issued).



A bond that matures in one year is much more predictable and thus less risky than a bond that matures in 20 years. Therefore, in general, the longer the time to maturity, the higher the interest rate. Also, all things being equal, a longer term bond will fluctuate more than a shorter term bond.







Issuer


The issuer of a bond is a crucial factor to consider, as the issuer’s stability is your main assurance of getting paid back. For example, the U.S. government is far more secure than any corporation. Its default risk (the chance of the debt not being paid back) is extremely small – so small that U.S. government securities are known as risk-free assets. The reason behind this is that a government will always be able to bring in future revenue through taxation. A company, on the other hand, must continue to make profits, which is far from guaranteed. This added risk means corporate bonds must offer a higher yield in order to entice investors – this is the risk/return tradeoff in action.



The bond rating system helps investors determine a company’s credit risk. Think of a bond rating as the report card for a company’s credit rating. Blue-chip firms, which are safer investments, have a high rating, while risky companies have a low rating. The chart below illustrates the different bond rating scales from the major rating agencies in the U.S.: Moody’s, Standard and Poor’s and Fitch Ratings.


Bond Rating Grade Risk
Moody’s S&P/ Fitch
Aaa AAA Investment Highest Quality
Aa AA Investment High Quality
A A Investment Strong
Baa BBB Investment Medium Grade
Ba, B BB, B Junk Speculative
Caa/Ca/C CCC/CC/C Junk Highly Speculative
C D Junk In Default



Notice that if the company falls below a certain credit rating, its grade changes from investment quality to junk status. Junk bonds are aptly named: they are the debt of companies in some sort of financial difficulty. Because they are so risky, they have to offer much higher yields than any other debt. This brings up an important point: not all bonds are inherently safer than stocks. Certain types of bonds can be just as risky, if not riskier, than stocks.

Understanding the price fluctuation of bonds is probably the most confusing part of this lesson. In fact, many new investors are surprised to learn that a bond’s price changes on a daily basis, just like that of any other publicly-traded security. Up to this point, we’ve talked about bonds as if every investor holds them to maturity. It’s true that if you do this you’re guaranteed to get your principal back; however, a bond does not have to be held to maturity. At any time, a bond can be sold in the open market, where the price can fluctuate – sometimes dramatically. We’ll get to how price changes in a bit. First, we need to introduce the concept of yield.



Measuring Return With Yield

Yield is a figure that shows the return you get on a bond. The simplest version of yield is calculated using the following formula: yield = coupon amount/price. When you buy a bond at par, yield is equal to the interest rate. When the price changes, so does the yield.



Let’s demonstrate this with an example. If you buy a bond with a 10% coupon at its $1,000 par value, the yield is 10% ($100/$1,000). Pretty simple stuff. But if the price goes down to $800, then the yield goes up to 12.5%. This happens because you are getting the same guaranteed $100 on an asset that is worth $800 ($100/$800). Conversely, if the bond goes up in price to $1,200, the yield shrinks to 8.33% ($100/$1,200).



Yield To Maturity

Of course, these matters are always more complicated in real life. When bond investors refer to yield, they are usually referring to yield to maturity (YTM). YTM is a more advanced yield calculation that shows the total return you will receive if you hold the bond to maturity. It equals all the interest payments you will receive (and assumes that you will reinvest the interest payment at the same rate as the current yield on the bond) plus any gain (if you purchased at a discount) or loss (if you purchased at a premium).



Knowing how to calculate YTM isn’t important right now. In fact, the calculation is rather sophisticated and beyond the scope of this tutorial. The key point here is that YTM is more accurate and enables you to compare bonds with different maturities and coupons.



Putting It All Together: The Link Between Price And Yield

The relationship of yield to price can be summarized as follows: when price goes up, yield goes down and vice versa. Technically, you’d say the bond’s price and its yield are inversely related.



Here’s a commonly asked question: How can high yields and high prices both be good when they can’t happen at the same time? The answer depends on your point of view. If you are a bond buyer, you want high yields. A buyer wants to pay $800 for the $1,000 bond, which gives the bond a high yield of 12.5%. On the other hand, if you already own a bond, you’ve locked in your interest rate, so you hope the price of the bond goes up. This way you can cash out by selling your bond in the future.









Price In The Market


So far we’ve discussed the factors of face value, coupon, maturity, issuers and yield. All of these characteristics of a bond play a role in its price. However, the factor that influences a bond more than any other is the level of prevailing interest rates in the economy. When interest rates rise, the prices of bonds in the market fall, thereby raising the yield of the older bonds and bringing them into line with newer bonds being issued with higher coupons. When interest rates fall, the prices of bonds in the market rise, thereby lowering the yield of the older bonds and bringing them into line with newer bonds being issued with lower coupons.

Bond Basics: How To Read A Bond Table

Customize System Properties Info of My Computer

C:\windows\system32\sysdm.cpl

Test Categories

Test Categories

Summary: Tests can be categorized into general buckets
Functional
BVT (small subset to check for build stability)
User scenario
Positive (all other functional cases not covered under user scenarios)
Boundary
Negative (error handling)
Security
Performance and Concurrency
Stress (including Fault injection)
Globalization / Localization
Usability
Accessibility (for UI)

BlogEngine.NET 1.4 and 1.4.5 Theme pack

BlogEngine.NET 1.4 and 1.4.5 Theme pack
Go check out the themes, they look and work great. Download the theme pack now.

Themes.zip (2.08 mb)

Using command redirection operators

Using command redirection operators

You can use redirection operators to redirect command input and output streams from the default locations to different locations. The input or output stream location is referred to as a handle

The following table lists operators that you can use to redirect command input and output streams.

Redirection operator

Description

>

Writes the command output to a file or a device, such as a printer, instead of the Command Prompt window.

<

Reads the command input from a file, instead of reading input from the keyboard.

>>

Appends the command output to the end of a file without deleting the information that is already in the file.

>&

Writes the output from one handle to the input of another handle.

<&

Reads the input from one handle and writes it to the output of another handle.

|

Reads the output from one command and writes it to the input of another command. Also known as a pipe.

By default, you send the command input (that is, the STDIN handle) from your keyboard to Cmd.exe, and then Cmd.exe sends the command output (that is, the STDOUT handle) to the Command Prompt window.

The following table lists the available handles.

Handle

Numeric equivalent of handle

Description

STDIN

0

Keyboard input

STDOUT

1

Output to the Command Prompt window

STDERR

2

Error output to the Command Prompt window

UNDEFINED

3-9

These handles are defined individually by the application and are specific to each tool.

The numbers zero through nine (that is, 0-9) represent the first 10 handles. You can use Cmd.exe to run a program and redirect any of the first 10 handles for the program. To specify which handle you want to use, type the number of the handle before the redirection operator. If you do not define a handle, the default < redirection input operator is zero (0) and the default > redirection output operator is one (1). After you type the < or > operator, you must specify where you want to read or write the data. You can specify a file name or another existing handle.

To specify redirection to existing handles, use the ampersand (&) character followed by the handle number that you want to redirect (that is, &handle#). For example, the following command redirects handle 2 (that is, STDERR) into handle 1 (that is, STDOUT):

1<&2

Duplicating handles

The & redirection operator duplicates output or input from one specified handle to another specified handle. For example, to send dir output to File.txt and send the error output to File.txt, type:

dir>c:\file.txt 2>&1

When you duplicate a handle, you duplicate all characteristics of the original occurrence of the handle. For example, if a handle has write-only access, all duplicates of that handle have write-only access. You cannot duplicate a handle with read-only access into a handle with write-only access.

Powered by WordPress | Theme: Motion by 85ideas.