Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > BOOK: Beginning Visual C#
|
BOOK: Beginning Visual C#
This is the forum to discuss the Wrox book Beginning Visual C#, Revised Edition of Beginning C# for .NET v1.0 by Karli Watson, David Espinosa, Zach Greenvoss, Jacob Hammer Pedersen, Christian Nagel, Jon D. Reid, Matthew Reynolds, Morgan Skinner, Eric White; ISBN: 9780764543821
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 20th, 2004, 07:03 PM
Authorized User
 
Join Date: Jul 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default Beginning Visual C# Exercises - Chapter 21 Answers

1. Modified AssemblyInfo.cs (inspired by a song)....
    [assembly: AssemblyTitle("Listen to Yardbirds Class Library")]
    [assembly: AssemblyDescription("Classes of Things To Come")]
    [assembly: AssemblyConfiguration("Beginner Lesson Version")]
    [assembly: AssemblyCompany("Yardbirds Said It All, Ltd")]
    [assembly: AssemblyProduct("Shapes")]
    [assembly: AssemblyCopyright("Copyright 2004, Yardbirds Said It All, Ltd")]
    [assembly: AssemblyTrademark("Shapes is a trademark of Yardbirds Said It All, Ltd")]
    [assembly: AssemblyCulture("")]

    [assembly: AssemblyVersion("1.3.*")]

    Build and then view via Ildasm....

2. Write a square class in MoreShapes with the circle and triangle...
    using System;
    using System.Drawing;

    namespace MoreShapes
    {
        public class Square
        {
            double Side;

            public Square() : this(0d)
            {
            }

            public Square(double givenSide)
            {
                Side = givenSide;
            }

            public double Area()
            {
                // area = Side squared
                return Side * Side;
            }
        }

        public class Circle
        {
            double Radius;

            public Circle() : this(0d)
            {
            }

            public Circle(double givenRadius)
            {
                Radius = givenRadius;
            }

            public double Area()
            {
                // area = pi r squared
                return Math.PI * (Radius * Radius);
            }

            public void Draw()
            {
                Pen p = new Pen(Color.Red);
            }
        }

        public class Triangle
        {
            double Base;
            double Height;

            public Triangle() : this(0d, 0d)
            {
            }

            public Triangle(double givenBase, double givenHeight)
            {
                Base = givenBase;
                Height = givenHeight;
            }

            public double Area()
            {
                // area = 1/2 base * Height
                return 0.5F * Base * Height;
            }
        }
    }

    Build and then view via Ildasm....

3. ShapeUser refers to MoreShapes assembly...
    using System;
    <s>//using Shapes;</s>
    using MoreShapes;

    namespace ShapeUser
    {
        public class ShapeUser
        {
            public static void Main()
            {
                double radius = 2.0;
                Circle c = new Circle(radius);
                Console.WriteLine("Area of Circle (2.0) is {0:f}", c.Area());
                Console.ReadLine();
            }
        }
    }

    Build and then view via Ildasm....

4. I just added code to the ShapeUser Class....
            public static void Main()
            {
                double radius = 2.0;
                Circle c = new Circle(radius);
                Console.WriteLine("Area of Circle (2.0) is {0:f}", c.Area());

                double side = 2.5;
                Square sq = new Square(side);
                Console.WriteLine("Area of Square (2.5) is {0:f}", sq.Area());

                double bottom = 3.0;
                double height = 1.5;
                Triangle tr = new Triangle(bottom, height);
                Console.WriteLine("Area of Triangle (3.0, 1.5) is {0:f}", tr.Area());

                Console.ReadLine();
            }

    Build and then view via Ildasm....

5. There is a lot of info to display so use the "more" pipe....
        gacutil /l | more
            - OR -
        gacutil /lr | more

6. Strong Name - nothing to show here - learn by doing....

7. Global Assembly Cache - nothing to show here - learn by doing....









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.