Tuesday, December 31, 2019
The Is The Mind, And A Physical Body - 1857 Words
Section 1: I believe there is a soul, which also is the mind, and a physical body. The argument that supports my belief the best will generate from the concept of a persons thoughts. I reject the belief that everything that is real must be in physical form. I believe there are both an immaterial part to you and a physical part. The physical part of you cannot survive without the immaterial. The immaterial part of a person is the soul, which I also believe, is the mind. However, your soul can live on without the physical sense of you. I believe that the physical part of you, your body, is acting like a cage to your soul. The body is kind of like a suit that your soul wears while it is on Earth. There is only one part of you that controls your actions and thoughts, which is your mind. Also, I believe that your body without a soul is just dead. If your soul and body are no longer at one then I believe you soul moves on to another world where your body is just dead. Once the soul and body are no longer connected the body has no purpose and has no actions. Since without the soul the body is nothing but matter then the soul is that part that is making all decisions, which is why I believe it is also the mind. It is the part of a person that m ake up a personality or gives a person reason. I believe the mind is the only part of a person that makes decisions and puts your physical body in action. With believing that the soul is in a body but the soul does not need the body, IShow MoreRelatedThe Mind and the Physical Body Essay586 Words à |à 3 PagesThe Mind and the Physical Body Since the times of Plato and Aristotle, the argument of dualism and mutualism of the mind and body has been in existence. Dualism has been the driving force behind the existence of the mind/body problem and has been by far the majority view due largely to the influence of Descartes. In recent times, modern medicine has taken a shift towards mutualism. Outside stimuli, as perceived by the mind, affects the body either beneficially or adversely. While the body asRead MoreI, Myself, And My Body1222 Words à |à 5 Pagesand My Body The mind is about mental processes and thought, while the body is the physical aspects of the brain. For years, philosophers have been perplexed by the mind-body problem. The mind is about mental processes and thought, while the body is the physical aspects of the brain. The mind-body problem discusses the mind and body, along with the relationship between them. Dualists and monists are the two types of people that take a stand on the issue. While Dualism may spilt mind and body, monismRead MoreThe Mind Body Problem : Interactionism And Physicalism1241 Words à |à 5 Pagestalked about concepts of philosophy is that of the mind-body problem. In short, the mind-body problem is the relationship between the mind and the body. Specifically, itââ¬â¢s the connection between our mental realm of thoughts, including beliefs, ideas, sensations, emotions, and our physical realm, the actual matter of which we are made up of the atoms, neurons. The problem comes when we put the emphasis on m ind and body. Are the mind and body one physical thing, or two separate entities. Two argumentsRead More How The Brain Works Essay1307 Words à |à 6 PagesCurrent research shows that mental events cause physical events, and scientists believe examining single nerves is the key to understanding how the brain works as a complete unit. Understanding the brain at the nerve cell level will allow scientists to understand how human consciousness works (Blakeslee, 1992). Furthermore, the brains thalamus is identified as the possible sensory connector because it fires 40 impulses per second that sweep through the entire brain (Blakeslee, 1995a). These findingsRead MoreThe Mind Body And Body1341 Words à |à 6 Pages The Mind-Body problem arises to Philosophy when we wonder what is the relationship between the mental states, like beliefs and thoughts, and the physical states, like water, human bodies and tables. For the purpose of this paper I will consider physical states as human bodies because we are thinking beings, while the other material things have no mental processes. The question whether mind and body are the same thing, somehow related, or two distinct things not related, has been asked throughoutRead MoreRelationship Between Mind And Body929 Words à |à 4 PagesIn philosophy, Mindââ¬âbody dualism is any theory that states that the mind and body are two distinct kinds of substances or natures. The problem of the relationship of the mind to body arose from the works of Renà © Descartes, a French philosopher and mathematician of the 17th-century who gave dualism its classical formulation or made it to be what it is today. Conceived from his famous ââ¬Å"Cogito, ergo sumâ⬠( Latin) meaning ââ¬Å"I think, therefore I am,â⬠he developed a theory of the mind as a nontangible andRead MoreDescartes s Meditations On First Philosophy917 Words à |à 4 PagesFirst Philosophy, Descartes introduces the dualistic idea of a sharp split between mind and body. This mind-body split is a Western secular idea and discounts many important aspects of the human experience. Descartes argues that, ââ¬Å"â⬠¦a body, by its very nature, is always divisible. On the other hand, the mind is utterly indivisibleâ⬠(Descartes, 56). This idea that there is a distinct difference between the mind and the body is nonsensical from both a phenomenological and a scientific perspective. FurthermoreRead MorePersonal Philosophy Of Sports And Physical Activity1121 Words à |à 5 PagesThe body is always seen as two parts working together, mind and body. We study these concepts as if they were separate, such as biology for the body and psychology for the mind. Taking two differ ent courses, one for mind and body, cause me to develop a dualism philosophy. After taking Kinesiology 305 Historical and Philosophical base of Kinesiology, I started to understand the body shouldnââ¬â¢t be seen as two things, but as seeing both mind and body equally important and should be devoted the same amountRead MoreIs the mind independent to the body?791 Words à |à 4 Pagesthe mind independent to the body? The mind body problem is a philosophical problem that is concerned with the relationship between the mind and the body, whether the mind exists independently of the body or whether the mind and body are one substance. There is a vital difference between the mind and the body some would say, meaning that the mind is held responsible for mental elements such as pain, euphoria, desire, purpose, belief and kindness whereas the body is responsible for the physical elementsRead MoreRene Descartes And George Berkeley1014 Words à |à 5 Pagesproblem of mind and body. I will look at the views of Rene Descartes and George Berkeley. I will be siding with Descartes. The mind-body problem ultimately encases the difficulty understanding how the mind and body interact, what they entail, and how they interact and communicate. Rene Descartes believed that the mind and body are two separate entities, as stated in ââ¬ËDescartesââ¬â¢s Dualismââ¬â¢. He held the notion that while the body is in fact a part of the physical world our minds are not. Our minds are the
Monday, December 23, 2019
Essay about Juliets Relationship with Her Parents
Relationships between teenagers and their parents are rarely boring. Since teenagers begin to think and act independently, conflict arises between them more frequently. This is not just a modern occurrence; in William Shakespeareââ¬â¢s The Tragedy of Romeo and Juliet, Juliet and her parents have very different points of view. In the play, she marries a man who is a member of a rival family without discussing it with her parents, which eventually leads to her demise because of the conflict that arises. She does not have much interaction with her parents throughout the play, but the miniscule amount shows the differing of opinions immensely. Julietââ¬â¢s limited interactions with her parents in the play show that she has a rebellious relationshipâ⬠¦show more contentâ⬠¦Ã¢â¬Å"An honour! Were not I thine only nurse, I would say thou hadst suckââ¬â¢d wisdom from thy teatâ⬠(1.3. 452). Her relationship with the Nurse was the opposite of the one she shared with her tru e parents and this lead Juliet to going to her Nurse whenever she had a predicament. This was counter-productive because these predicaments that she went to her Nurse for help lead to her dying because it was the Nurseââ¬â¢s obligation to side with Juliet and do what she was asked, even if it opposed what her parents would have approved. These jobs that Juliet set her Nurse out to complete were rebellious of what her parents would have wanted her to be doing. It was still a healthier relationship than the one that Juliet shared with her mother and father, which was significant considering the fact that she was a teenager when she faced all the issues that came with her forbidden love. Juliet and her father definitely had different ideas about her future relationships in this play. Back in that time period, the father of the family was the one who made important decisions for their children, which included who his daughter was allowed to get married to, even if they opposed their preference. So, in the play, Lord Capulet gives his approval to a man named Paris to marry his daughter because he had a promising future and was very prosperous and could provide Juliet with anything she might require. Although she had this option of spouse, she choseShow MoreRelatedJuliets Relationship With Her Parents in William Shakespeares Romeo and Juliet1315 Words à |à 6 PagesJuliets Relationship With Her Parents in William Shakespeares Romeo and Juliet Lord and Lady Capulet have a distant, but affectionate relationship with their daughter, Juliet. At the beginning of the play, the parents think that Juliet is a respectful girl and listens to the parents needs. Lord Capulet has a positive and loving attitude towards Juliet at the beginning. This is proven in Act 1 scene 2 when Lord Capulet and County Paris are having a conversation on marriageRead MoreParent Child Relationship Between Juliet And Juliet Essay1391 Words à |à 6 PagesParent-Child Relationship in Romeo and Juliet Parent-Child relationships are among one of the most complicated ones but also some of the most rewarding. The structure of the Parent-Child relationship has changed significantly over time. Parents do not treat their children the same way they did during the late 1500s. William Shakespeareââ¬â¢s famous play Romeo and Juliet illustrates how Parent-Child relationships were during this time and how complicated they could be. An excellent example of a complicatedRead MoreRomeo And Juliet Gender Roles1489 Words à |à 6 PagesJuliet, as she gains power and control over her own life by opposing her parentsââ¬â¢ traditional ideals. Due to the ancient grudge between the Capulets and the Montagues, Julietââ¬â¢s relationship with Romeo is not socially acceptable. Her parentsââ¬â¢ blind judgment forced Juliet to formulate a secret relationship in order to maintain control over her life, eventually displaying her strength and power, as she defies the obedient nature of stereotypica l females. Despite her age, Juliet was able to overlook the animositiesRead MoreRomeo And Juliet Female Character Essay997 Words à |à 4 PagesJuliet, as she gains power and control over her own life by opposing her parentsââ¬â¢ traditional ideals. Due to the ancient grudge between the Capulets and the Montagues, Julietââ¬â¢s relationship with Romeo is not socially acceptable. Her parentsââ¬â¢ blind judgments forced Juliet to formulate a secret relationship in order to maintain control over her life, eventually displaying her strength and power, as she defies the obedient nature of stereotypical females. Despite her age, Juliet was able to overlook the animositiesRead MoreHardships In Romeo And Juliet940 Words à |à 4 Pagesbrilliant story of Romeo and Juliet, the story that not only captivates and thrills readerââ¬â¢s minds but offers insight to how a flawed relationship can end in a tragedy. Unfortunately, due to sin, all relationships including that of Romeo and Julietââ¬â¢s have their ups and downs. Today the most commonly known flawed relationship is the relationship between a teenager and parent. Perhaps this is because of opposing ideas or lack of communication but never the less the true weakness will always fall back toRead MoreThe Nurse And Juliet By William Shakespeare877 Words à |à 4 Pagesclosely bonded relationship. The nurse lost her only child Susan and replaces her feelings of loss for the passing of her only child with love for Juliet. ââ¬ËI bade her some. What, lamb! What ladybird! God forbid, whereââ¬â¢s this girl? What, Juliet!ââ¬â¢ the use of terms of affection show the nurses enthusiasm and eagerness towards Juliet. The nurse uses frequent anecdotes of her and Juliet, ââ¬Ëtis since the earthquake now aleven years, and she was weaned ââ¬â I shall never forget itââ¬â¢ she shows her love throughRead MoreWilliam Shakespeare s Romeo And Juliet1342 Words à |à 6 Pagesrestricting of their relationshi p. Their identity, as in age, social class and gender, prevents the two protagonists from achieving purity in their relationship. The story heavily relies on these aspects of Romeo and Julietââ¬â¢s life ââ¬â contributing to the overall well-being of their love and chemistry, throughout the romance and tragedies that are presented in the play. Romeo and Julietââ¬â¢s relationship is defined by family affiliation ââ¬â like a typical teenage love story, when the parents do not always approveRead MoreRomeo And Juliet Loyalty Essay1563 Words à |à 7 Pageskill. Same can be said for loyalty, when practiced consciously and cautiously it can be a healthy relationship but when the loyalty strays from its original path an. In William Shakespeareââ¬â¢s tragic play, ââ¬Å"Romeo Julietâ⬠, Shakespeare suggests that Julietââ¬â¢s inclination to loyalty for Romeo leads her down this spiral which leads her to lie to her parents, and even go as far as to kill herself because of her loyalty towards Romeo. When an Individual is introduced to new loyalties in their life, they shouldRead MoreEssay on Juliets State of Mind in Shakespeareà ´s Romeo and Juliet842 Words à |à 4 Pages Julietââ¬â¢s love and loyalty towards Romeo, and her developing character do not only play an important role in motivating her in s peaking the lines that she does, but also in motivating her actions. Despite all the current events that have occurred; events that have affected her state of mind, Juliet decides to remain true and faithful to Romeo. Julietââ¬â¢s state of mind at this point in the play definitely revolves around this idea of light vs. dark ââ¬â her fears and hopes. After hearingRead MoreCharacter Analysis Of Romeo And Juliet1027 Words à |à 5 PagesJuliet in situations where she is faced with pressure from her family, friends and society. However, throughout these conflicts and meeting Romeo, Julietââ¬â¢s character becomes stronger, more confident and mature, resulting in the development of her character throughout the play. The audience is able to recognize her growth and maturity through her innocence at the beginning, her sudden marriage to Romeo and a shift in behaviour towards her parents and others. During Elizabethan times, it was very difficult
Sunday, December 15, 2019
Why We Should Brush Our Teeth Free Essays
Nicholas Ruiz VPA 192 Informative Speech Why we should brush our teeth Goodmorning, Let me ask have you ever been on the train and been sitting next to someone with terrible breath? Or been on a date and you kiss the person your with and they have a horrid smell seeping out of there mouth. These simple smelly encounters would be easily avoided if we all keep up with out oral hygiene. My name is Nicholas Ruiz and today I am here to inform you of how to keep your oral hygiene up to par and why it is so important to do so. We will write a custom essay sample on Why We Should Brush Our Teeth or any similar topic only for you Order Now As a dental assistant for the past 3 years I have been taught to show people how to keep the general oral hygiene were it should be. A couple of the most commonly asked questions I get is what kind of tooth brush should I use or what kind of tooth paste they should use. I tell them a soft brisal toothbrush(show soft toothbrush) is the way to go and any kind of toothpaste with Fluoride in it will work. I spoke with a doctor in my office Dr. Tad Picker he stated,â⬠I always recommend a soft brisal toothbrush.It nurtures your teeth while you brush as were a firm brisal toothbrush can wear away the enamel of your teeth. (show firm toothbrush) And when it comes to toothpaste I say aslong at it has Flouride in it it is ok. Me personally I use Aquafresh. â⬠Also, an equally big part is flossing everyday. You can be fantastic at brushing your teeth but only floss can get into those nasty area that your couldnââ¬â¢t get when you brush. Finally, a good product to use is Listerine it really does kill any of those excess germs left in your mouth after brushing.Now you should be brushing your teeth 2 times a day. I brush 3 times a day but thatââ¬â¢s just a preference. Now when you get ready to brush your teeth, you donââ¬â¢t glob the toothpaste on like in the commercials with the little tale like in the commercials. (Show how not to apply toothpaste) You apply as small but sufficient amount of paste. (Show how to apply toothpaste) Now when you begin to brush you suppost to do it on a 45 degree angle as so â⬠¦like your messaging your teeth. show example) Brushing hard does not help in your efforts to keep your teeth clean. It pushes the germs and everything in your mouth further down and makes it harder to reach. Now let me ask you why is it so important to brush and what happens when you donââ¬â¢t. ( Let audiences react) A lot of great answers. It is important because not only does oral hygiene effect your mouth but it can also effect other parts of your body such as your heart. Oral hygiene is a very important ingredient to the collection of things that keep your body balanced.Now when you donââ¬â¢t brush your teeth what happens is that any food that you eat stays on your teeth which breakdowns to sugars which turns into acids that burns away your tooth enamel. This cause things such as cavities and other infections. In conclusion oral hygiene is and should be a major part of your daily life. It is important that you have the right tools to be able to keep up with it. If kept up with your teeth with stay healthy and you wont have to wear those bulky dentures. Thank you. How to cite Why We Should Brush Our Teeth, Papers
Saturday, December 7, 2019
Tort Scenario free essay sample
Tort Actions The most prevalent tort in scenario 2 is negligence. The first act of negligence would be the glass that was found in Annaââ¬â¢s food that caused her injury. The second negligent act was the waiterââ¬â¢s decision to carry a flaming dish through the restaurant without announcing his presence. The restaurant ownerââ¬â¢s negligent decision to not install an emergency exit other than a revolving door entrance caused an elderly woman to be trampled and caused several other patrons to suffer from smoke inhalation and burns.Anna also has a medical malpractice tort because when she was taken to the hospital to have surgery on her mouth a hospital mistake resulted in her leg being amputated instead. Potential Plaintiffs The potential plaintiffs in this case are Anna, the elderly woman that was trampled, the waiter who was burned, and the restaurant patrons that suffered smoke inhalation and burns. Possible Defendants Possible defendants are the cooks because of their negligence and actions that caused Anna to be served a dish with glass in it to begin with. We will write a custom essay sample on Tort Scenario or any similar topic specifically for you Do Not WasteYour Time HIRE WRITER Only 13.90 / page The waiter is a possible defendant because he failed to announce his presence and was responsible for tossing his apron onto another tablecloth starting a larger blaze. The restaurant owner is another possible defendant because they failed to provide a proper emergency exit. Defendants of the malpractice tort are both the doctor who performed the wrong surgery on Anna and the hospital in which the mix up took place.The surgeon failed to ensure he was performing the right procedure on the right patient and the hospital because they failed to have standard operating procedures in place that would prevent such a horrible mishap. Tort Elements Anna can claim negligence against the restaurant and its owner because their breach of duty to care caused for Anna to injure her mouth when she bit down on glass that was in her food.Anna can claim malpractice against the hospital and the doctor that mistakenly amputated her leg instead of performing surgery on her mouth! The elderly woman and the patrons of the restaurant can claim negligence against the restaurant owners because of their failure to install a proper emergency exit. Defenses In this case it is possible that the defendants- the restaurant owner and waiter, could try and use the defense that patrons entering the restaurant do so with a certain amount of assumed risk.They may try to say that patrons are fully aware of the types of dishes (including the flaming dishes that started this incident) and that the patrons enter the restaurant at their own risk. It is possible that the cooks may try to claim that the glass was put into the meal after it left the kitchen and that they are not responsible. The restaurant owners may try to dismiss the patronââ¬â¢s claims of negligence and claim that those injuries would still have occurred if there had been another emergency exit.The restaurant owners may claim that the smoke inhalation and burns were not because of the revolving door exit, but rather the fault of the patrons being frantic. Claim Resolution Anna has two strong claims in this scenario. The first claim is her negligence claim against the re staurant because of the glass in her food. This incident is directly responsible for Anna being taken to the hospital where her malpractice claim took place when doctors mistakenly amputated her leg.The elderly woman has a strong case again the building owners because she suffered injuries being trampled while other patrons were trying to squeeze through the revolving door. The staff and patrons that suffered injuries might have a more difficult time proving their case because the smoke inhalation and burns might have occurred regardless. If taken to trial the judge could also decide that the waiter dropping the flaming plate was an accident and therefore the following injuries were the result of an accident and not negligence.
Friday, November 29, 2019
Why did it take Lincoln so long to allow blacks to join the military and fight for the north in the Civil War Essay Example Essay Example
Why did it take Lincoln so long to allow blacks to join the military and fight for the north in the Civil War? Essay Example Paper Why did it take Lincoln so long to allow blacks to join the military and fight for the north in the Civil War Essay Introduction The inauspicious commencement of the Civil War signalled that the war would not be a brief affair, even if such briefness had earlier been anticipated. The first battle christened the Bull Run on July 21 1861, pitted federal troops numbering 30,000 under General Irvin McDonell against Confederate troops numbering 22,000 under General P.G.T. Beauregard.1 The defensive superiority of the Confederates rent a major blow to the budding press corps. This was just the beginning. Even though the Union forces desired to increase their manpower concerns in the white American mind rent questions as regards the black manââ¬â¢s degree of intelligence, humanity and common sense. These questions and doubts created a situation in which the Lincoln administration was unsure of which side the African Americans slaves would take in the conflict between the Union and the Confederacy. Most whites believed that blacks could barely comprehend the nature of the war. Moreover, the degree of their loyalty to their slave masters rendered them irrelevant to the overall outcome of the conflict.1 These initial doubts to the recruitment of the black soldier were answered unambiguously just within the initial weeks of the war. As the Union forces advanced and occupied South Carolina Sea Islands, slaves escaped from the plantations and joined the Union army lines. To understand the developments in the Civil War, a concise exposition is worthwhile. The Civil War gave the slave population the opportunity to actively engage in their own emancipation and become free men. Even though major slave uprisings were absent and not more than a quarter of the overall slave population made it in the Union lines, slavery disintegrated as the Union Armies moved with irreversible momentum into the slave territories.2 Through the act of seizing their freedom whenever opportune, African Americans became enshrined into a self-emancipation process. The process was to extend to almost all spheres of their lives leading into the reconstruction. After Lincolnââ¬â¢s Emancipation Proclamation on January 1, 1863, the black quest for freedom was converted into an official war aim. Even though the proclamation was historically congruent to Lincolnââ¬â¢s constitutional scruples, the ramifications of the proclamation itself was lost on the general public who viewed it as nothing but a general moral anti-slavery crusade. Why did it take Lincoln so long to allow blacks to join the military and fight for the north in the Civil War? Essay Body Paragraphs However, blacks began to sense that the war against the Confederacy was a war for their own liberation; the war was caused by their being slaves and that the end result of the war would be their eventual freedom.3 Therefore as federal forces advanced, they acted as a magnet; attracting slaves from the adjacent areas. The first attraction of such kind occurred in Charleston, South Carolina, Savannah and Georgia. Geographically these areas covered rice and sea island plantations. As more and more blacks hurried into the Union enclaves, the surrounding areas which had hitherto been ripe in slavery collapsed. As the Union armies moved into New Orleans, thousands of blacks moved into Union camps resulting in the collapse of slavery in the entire lower Mississippi. This ripple effect was repeated as the Union forces advanced into new areas. In New Orleans the Southern myths that blacks were docile were blown away when the black populations decided to release years of accumulated hostility and anger. The slaves seized the lands for their own use, drove off overseers, stopped working or fled to the Union camps.4 As blacks continued to pour into contraband camps, the mortality rates increased averaging approximately 25%. In line with the Union policy, these refugees received employment in whatever capacity that was deemed useful to the Union war effort. Both the Navy and the Army organized labour battalions of the increasing black population for work as teamsters, construction hands, laundresses, and cooks and so on. In practice, the employment was akin to imposition of forced labour controls by the military. Thus, the refugees received pay but these wages were way below what their white counterpartsââ¬â¢ received. A greater number were also leased out, according to the terms of employment drawn by federal commanders and the conferences and local planters or superintendents representing Northern freedmenââ¬â¢s aid societies, to work in plantations that had been se ized by the Union forces. Amid these employment options, the eagerness of blacks to fight for their cause could not be vanquished because since the war began, blacks had tried, albeit unsuccessfully, to register in enlist in the Union Navy and Army.5 On April 23 1861; a black employee of the United States senate: Jacob Dobson drafted a letter to the Secretary of War to express his determination as well as that of other three hundred Black Americans to militarily play a part in defending their capital. In New York, Black men independently organized drilling sessions in preparation for the war. In a rally held in Boston in April 1861, blacks expressed their wish that the statutes prohibition their enlistment in the United States army be abolished. Despite all these, Lincoln still held profound doubts about the character of black males. He feared that if blacks were to be armed, then in a few weeks time the same arms would be in the hands of the rebels.1 On another occasion Lincoln rei terated that should blacks be enlisted in the army then it would be akin to betraying the political realities that existed at that time. He was disturbed that such an enlistment would turn the fifty thousand bayonets originating from the Border States that were loyal against the Union. During the war there existed a popular sentiment that the Civil War was a white mans war. Others feared that enlisting the black man into the army increased their probability of being successful in the battlefield hence making the black man gain additional respect that the white had no intention of extending to their black brethren. Added to these concerns, was the discriminatory attitudes among the white soldiers who believed that it was extremely deteriorating to fight alongside a race they considered too inferior. It is prudent to note that during this period, the white male was viewed as being too cowardly and an unthinking menial. Such an image was extrapolated to imply that they when recruited t hey would be poor soldiers In 1863, Lincoln made a bold step that created the program for the enlistment of black soldiers into the federal forces. At the onset of the program, the insecurities of the Northern white supremacist majority were immediately aroused as they thought that the Union and its gains may be tainted if blacks shed blood in their own defence or in the process of liberating the remaining slaves. This was one of the reasons that Lincoln had delayed the recruitment of blacks in the Union forces. The presence of political risks posed by white backlash as well as the military danger that such a move would lead to a drop in morale other challenges to the recruitment of blacks in the army. However, he overcame these challenges by successful implementing the policy whose main aim was to increase manpower in the Union armies. Eventually, the policy enabled the recruitment of 200,000 Afro-Americans in the Union military.2 The recruitment of blacks into the military did not instantaneously transform the northern racial attitudes; in fact it exacerbated racial tensions and intensified the Democratic opposition to the emancipation. The black soldiers were segregated, given meagre pay, commanded by white officers and deemed fit for the labour battalions and the garrison.6 As blacks transformed the war into a revolution intent on throwing out the old order, Lincoln attitude towards the policy changed from that of reluctance to that of enthusiasm. Blacks soldiers fighting for their own liberation signified the progress in the revolution that Lincoln had started by the Emancipation Proclamation. In the South, the response to black enlistment was ferocious both on paper and practically. Upon hearing of the policy, General Beauregard called for the execution of black Union soldiers. A sober analysis of the Generals policy prevented the enforcement of such an order but there were evidences of the execution of black soldiers in the South either in the battlefie ld or thereafter. Reports and rumours of such massacres caused a vexation among the Union authorities during the entire war period. This was one of the main reasons why Lincoln had initially hesitated to enlist blacks in the Union army as combatants since they had a high risk of capture. Moreover, the Confederate utterly refused to treat black soldiers who were captured as legitimate prisoners of war. This refusal eventually led to the breakdown of prisoner of war exchanges. As the war strode on attitudes that has delayed their recruitment in the Union Army began to change. There are those who believed that recruiting blacks was a sure way of saving whites from dying in the battlefield. Expanding the ranks with black men also served in hastening the war towards its end. Despite the difficulties these black soldiers faced such as discrimination from white soldiers, white men, bad food, cold winter quarters, boredom, loneliness, hard drilling hours, dirt and diseases, they endured the m all. On the other hand, they were earning a reputation for exhibiting courage under fire, winning heroic invasions on Confederate territory.7 Numerous accounts of unflinching courage among colored regiments finally silenced the critics of the emancipation and black enlistment. However, from the first day that the blacks entered into the battlefield they faced greater perils than the white soldiers. As prisoners of war, they were either shot or hanged. In reaction, Lincoln threatened the confederates that for every single soldier shot or hung, the same will be done to rebel prisoners of war. It was this threat that led to the cessation of prisoner exchanges as the South refused to hand over black prisoners of war and so the execution by the South continued, but these actions could not stop blacks from enlisting into the army. As the Civil war ended, between 180,000-200,000 African Americans had adorned the Union uniform; constituting 10% of the Northern Army. We will write a custom essay sample on Why did it take Lincoln so long to allow blacks to join the military and fight for the north in the Civil War? Essay Example specifically for you for only $16.38 $13.9/page Order now We will write a custom essay sample on Why did it take Lincoln so long to allow blacks to join the military and fight for the north in the Civil War? Essay Example specifically for you FOR ONLY $16.38 $13.9/page Hire Writer We will write a custom essay sample on Why did it take Lincoln so long to allow blacks to join the military and fight for the north in the Civil War? Essay Example specifically for you FOR ONLY $16.38 $13.9/page Hire Writer
Monday, November 25, 2019
Mayhem and Maiming
Mayhem and Maiming Mayhem and Maiming Mayhem and Maiming By Maeve Maddox A series of insurance ads personifies insurable disaster as a man who causes various kinds of property damage. The ads always end with the character saying, ââ¬Å"be protected from mayhem like me,â⬠spreading the idea that mayhem means, ââ¬Å"damage.â⬠Mayhem shares its origin with the verb maim, which originally meant ââ¬Å"to wound or cause bodily hurt or disfigurement.â⬠In current usage, maim means ââ¬Å"to mutilateâ⬠or ââ¬Å"to cripple.â⬠Twin Blasts Kill 3 and Leave Scores Maimed, Wounded Children maimed, tortured in Syria, says damning UN report A new generation of maimed veterans is coming home with critical needs that overwhelm existing care facilities and devastate their families. As a term in criminal law, mayhem retains the meaning of inflicting physical injury on a person. Mayhem is a crime in which tremendous violence is done onto the victim.à [] to prove the defendant guilty of mayhem, the prosecution needs to prove that the defendant had malicious intent to maim or disfigure, cuts or maims an ear, nose, lip or cuts off or disable limb of another person. (site of a Boston attorney) In ordinary speech, mayhem is used to refer to any kind of violent behavior or disorder. A surfersââ¬â¢ event in Huntington Beach, Calif., ended in mayhem late Sunday, as riot police were called to the streets to disperse violent crowds and break up numerous fights. Akm Antivirus 2010 Pro is a virus that is causing mass mayhem around the internet by infecting thousands of PCs. Current mayhem in the financial sector opens up an opportunity for Nigeria to rid itself of the political and economic cancer it has endured for decades. U.S. Secretary of State John Kerry said that Yanukovych must decide between protecting the people that he serves all of the people versus violence and mayhem. The word maim always denotes a crippling injury. Apart from legal use, mayhem may refer either to physical injury or to violent behavior that does not necessarily lead to injury. Want to improve your English in five minutes a day? Get a subscription and start receiving our writing tips and exercises daily! Keep learning! Browse the Vocabulary category, check our popular posts, or choose a related post below:Passed vs Past5 Lessons for Mixing Past and Present TenseCapitalizing Titles of People and Groups
Friday, November 22, 2019
Criminal justice Thesis Example | Topics and Well Written Essays - 1000 words - 2
Criminal justice - Thesis Example There have been a number of issues however that have been raised when dealing with medical experimentation especially when the test subjects are human beings. This has to do with medical ethics and the right of going about seeking test subjects as well as the process of the experiments themselves. One of these issues is the matter of using prisoners to conduct medical experiments on various diseases such as AIDS and Hepatitis C when seeking cures. The argument behind the use of prisoners for the conducting of medical experiments in these areas is the fact that there is a higher prevalence of these diseases in the prison populations as compared to other groups and thus it is generally a convenient approach whilst seeking test subjects (Epstein, 2009, pg38). However, it has to be considered whether it is right to use prisoners as guinea pigs for medical experiments, or is it a type of discrimination on the part of the medical researchers (Tauber, 2005, pg18). This subject can be said to have both pros and cons when put into, and the issue is if the pros outweigh the cons considerably enough to win the day. There are a number of advantages to be considered by using prisoners as test subjects for new drugs to combat these diseases. These advantages have to do with the situation at hand and the potential positive outcome should the drugs be successful. They include: Situational advantage ââ¬â Prisoners are in a position where they reside in a controlled environment and thus this would make it easier for researchers to ensure that the test subjects are placed in a conducive environment for the conduction of the research (Lakhan et al, 2009, pg 12). For example, this is to say if the subject is not supposed to take any alcohol during the test period, this would not be a problem as they have no access to any liquor. Since the test subjects are all located in one area for the entirety of the test period, observation also becomes a simpler process as
Wednesday, November 20, 2019
Cross-Cultural Enterprise Management Essay Example | Topics and Well Written Essays - 4000 words
Cross-Cultural Enterprise Management - Essay Example Focus of the paper will be towards emphasizing the importance of effective cross cultural management in an enterprise and to what extent this affects the survival of the enterprise. Cross-cultural management is particularly important for the operation of an enterprise to gain the requisite advantage in the fiercely competitive world. If the problem of cultural conflict in an enterprise is not handled well, it might influence the entire working environment of the enterprise and make the task of management more complex and the decision-making and implementation of multinational operation more difficult. Such problems might restrict the selection of human resources from native or overseas market, products and services. The impact of cultural conflict on the transnational business happens to be quite comprehensive, systematic affecting the entire process. This study will center on the cross-cultural enterprise management to analyze the problems in enterprise cultural management and prese nt possible solutions which are of a certain guiding significance to some of the UK companies On the basis of successful and unsuccessful case analyses of overseas investments by some of the UK companies or by some MNCs in UK, the study tries to put forward general theories in such a manner that the study proves to be of some help in future research work. Background Cross-cultural management in essence means managing different cultures with effective coordination amongst the cultural groups and management teams of different cultures with its impact on organizational behavior, effective communication with people who come from different countries and cultural backgrounds. (Li,C & Lu,C, 2000) Along with the rapid development in the economic field and globalization and integration of economies, the role of corporate culture is becoming increasingly significant in upgrading enterprise competitiveness. Different culture backgrounds, values, enterprise management modes, politics, beliefs and cultures as well as racism and communication misunderstanding will give rise to corporate cultural conflicts. Cultural conflicts will in turn affect the relationship between multinational management and local employees and may lead to a loss in market opportunity and organizational efficiency, thus hampering the implementation plans of global strategies of multinat ionals. The so called "cultural conflict" refers to the process of confrontation and repulsion between different cultures or cultural elements, which not only includes the conflict arising from cultural difference between multinationals and countries where multinationals operate but also the conflict among internal employees from different cultural
Monday, November 18, 2019
LAND LAW Essay Example | Topics and Well Written Essays - 3750 words
LAND LAW - Essay Example He was not regular in visiting his property since he purchased it in year 1952, when he had asked his seller to plant Christmas trees on the land with the idea of harvesting it in later years. However, he could not tend to his land since he was posted at Bonn between the years 1955 to 1967. Subsequent to his return, between the years 1967-1972, the McFarlaneââ¬â¢s could make few visits to the property site, but it was clear that his interest in his property was waning. The McFarlanes did not suspect that their land was under the possession of Powell until, in 1972, they noticed the new fencing on their land, which gave rise to suspicion in their minds that perhaps all was not well regarding their claims to the stated property. Powell brought action stating that he was in adverse possession of the said disputed land since 12 years from the period 1960 to1972.In order to substantiate this statement, he had to prove that he had actual possession and control over the said land for the last 12 years. The facts, as observed by Slade J, were that for a person to be in possession, whether legal or illegal, he should be able to bring action for trespass, against any trespasser or squatter, who comes into the said land, without his permission. This is except in the case of a person who has a better title to the land then what he himself has.. In other words, he had to maintain animus possidendi.This means that, when the law has to attribute possession of a land to person who does not have paper title on the said land, he must be in a position to prove that he has both the factual possession as well as the requisite intention to possess the said land. (Farlane 1977). The main issue in the event of alleged possession is that the squatter is dealing with the land as though it is his own, and in a manner that would be used by the true owner, and nobody else. The essence of animus posited is that the squatter, in his own
Saturday, November 16, 2019
John Dalton And Atomic Theory
John Dalton And Atomic Theory John Dalton was the originator of atomic theory, which theory provided scientists with new ways of seeing the physical world. Atomic weights and fixed ratios of atoms inside compounds provided researchers with the knowledge to explore chemical compositions of matter. Daltons new information on atomic weights allowed a Russian chemist, Dmitry Mendeleyev, to create the periodic table of elements. This table provided the means for discovering new elements, and Dalton also proposed symbols for the elements. The symbols would represent the atom combination in compounds, but these were later changed to the abbreviations known today. Daltons theory had been accepted at the time, but it opened new questions about atom interactions. The structure and interaction of atoms refined atomic theory. Until Dalton, the line between physics and chemistry was almost unnoticeable, but his atomic theory distinguished and divided the two disciplines. In physics and chemistry, the atom is a cornerstone providing an understanding of matter and force, especially in quantitative analysis. Quantitative analysis refers to the measurement of how much of a certain substance is within a sample. Daltons theory was the beginning of nuclear energy and fusion research still used today. The theory also provides for the study of the quantitative relationships between substances in chemical reactions, or stoichiometry. It provides for structural theory and arrangements of atoms for influencing properties. Daltons models eventually turned into the understanding of 3-dimensional qualities of molecules and the affect of structure on properties. Daltons theory did have some inaccuracies, but it did provide the foundation for future generations of scientists. Atomic theory is the idea that matter is made u p of little units called atoms. In 1897, the British scientist J.J. Thomson discovered that atoms are in fact made up of smaller particles. Today atomic theory refers to matter being made up of units that are indivisible only some of the time. Dalton concluded that evaporated water exists in air as an independent gas. He wondered how water and air could occupy the same space at the same time, when obviously solid bodies cant. If the water and air were composed of discrete particles, Dalton reasoned, evaporation might be viewed as a mixing of water particles with air particles. He performed a series of experiments on mixtures of gases to determine what effect properties of the individual gases had on the properties of the mixture as a whole. While trying to explain the results of those experiments, Dalton developed the hypothesis that the sizes of the particles making up different gases must be different. John Dalton published the first table on relative atomic weights that included six elements viz. hydrogen, oxygen, carbon, nitrogen, phosphorous and sulfur. He stated the atomic weight of hydrogen to be 1. It was not confirmed as to how he derived the atomic weights. However, his laboratory notebook indicated that he found out the relative weights from the studies of the compounds water, carbon dioxide and ammonia. In his notebook, the elements were represented by symbols. He was the first person to propose the idea of identifying an element by its symbol. Later on, elements are represented by their abbreviations, for example, H is the abbreviation of the element hydrogen. While the concept of atoms was thus being made indispensable, the ancient belief that they were probably structure less and certainly indestructible came under devastating attack. J.J. Thomsons discovery of the electron in 1897 soon led to the realization that the mass of an atom largely resides in a positively charged part, electrically neutralized by a cloud of much lighter electrons. A f ew years later Ernest Rutherford and Frederick Soddy showed how the emission of alpha and beta particles from radioactive elements causes them to be transformed into elements of different chemical properties. By 1913, with Rutherford as the leading figure, the foundations of the modern theory of atomic structure were laid. It was determined that a small, massive nucleus carries all the positive charge whose magnitude, expressed as a multiple of the fundamental charge of the proton, is the atomic number. An equal number of electrons carrying a negative charge numerically equal to that of the proton form a cloud whose diameter is several thousand times that of the nucleus around which they swarm. The atomic number determines the chemical properties of the atom, and in alpha decay a helium nucleus, whose atomic number is 2, is emitted from the radioactive nucleus, leaving one whose atomic number is reduced by 2. In beta decay the nucleus in effect gains one positive charge by emitting a negative electron and thus has its atomic number increased by unity. Rutherfords gold foil experiment, performed in conjunction with Geiger and Marsden, provided evidence for the nucleus due to the scattering of alpha particles. The protons. Further work by Chadwick revealed the existence of neutrons within the nucleus of the atom. The atomic number describes the number of protons in the nucleus. For a neutral atom this is also the number of electrons outside the nucleus. Subtracting the atomic number from the atomic mass number gives the number of neutrons in the nucleus. Isotopes are atoms of the same element they have the same number of protons, or the same atomic number which have a different number of neutrons in the nucleus. Isotopes of an element have similar chemical properties. Radioactive isotopes are called radioisotopes. Most of the elements in the periodic table have several isotopes, found in varying proportions for any given element. The average atomic mass of an el ement takes into account the relative proportions of its isotopes found in nature. A nuclear binding force holds the nucleus of the atom together. The nuclear mass defect, a slightly lower mass of the nucleus compared to the sum of the masses of its constituent matter, is due to the nuclear binding energy holding the nucleus together. The mass defect can be used to calculate the nuclear binding energy, with E = mc2. The average binding energy per nucleon is a measure of nuclear stability. The higher the average binding energy, the more stable the nucleus. The basic difference between Rutherfords Atomic Theory and the Plum Pudding Model has to do with the fact that the Plum Pudding Model theorized that an atom was made up electrons the plums surrounded by a positively charged mass the pudding. Rutherford later proved that this wasnt the case and theorized that atoms were comprised of a very small nucleus surrounded by electrons. The basic tenets of that statement are still held to be true in the modern era. The chief difference is the fact that Niels Bohr, when theorizing the design of the atom, included a thesis for the forces that help to hold the atomic structure together. The Bohr model is still widely accepted by contemporary scientists. The Bohr model of the atom was established in 1913 as the leading theory of atomic structure. Because of this, it can be truthfully said that Rutherfords Atomic Theory was an extremely short-lived phenomenon. Despite its brief time frame, however, Rutherfords theory was extremely important because Niels Bohr wouldnt have been able to develop his own model without the established background that Rutherfords Atomic Theory laid out for him. www.angelfire.com/sc2/atomtheory/ www.iun.edu/~cpanhd/C101webnotes//dalton.html www.angelfire.com/sc2/atomtheory/ www.chemprofessor.com/atomic.htm www.nobeliefs.com/atom.htm www.chemlin.net/chemistry/atomic_theory.htm
Wednesday, November 13, 2019
No School Should Usurp the Rights of Any Student Essays -- Teaching Ed
No School Should Usurp the Rights of Any Student à à à à à Children are forced to go to school. This has been the way for a long time. School is a place where students go to learn a curriculum given by government officials. They are not there to get their rights taken away from them. Although teachers have power, they cannot stop students from hearing the issues, speaking without censorship, or knowing their rights. à à à à à Students are living, breathing human beings. We go to school to learn about and succeed in the outside world. Government officials are to teach us these things and see how well we learn them. We are curious creatures. We need to know everything or else we will rebel. Teachers should tell us both parts of a certain subject to allow objectivity in our minds. If we hear only one side of a controversial issue we tend to assert ourselves with the only point of view. We may also find out information on our own that is bad and believe what we find out. Teachers are here to guide us to the correct information. If a teacher takes a side he/she may tell us only the negative points to his opposing side. He/she may, also, just tell us good points about his side. Either way, he/she gives us a one sided perception. We need to hear both sides in order to make up our own minds. à à à à à Many believe that teachers have more power than students. This is a weak argument because teachers cannot remove rights of students. The Supreme Court stated this: ââ¬Å"It can hardly be argued that either students or teachers shed their constitutional rights to freedom of speech or expression at the school house gateâ⬠(Tinker vs. Des Moines Independent School District). Therefore, students are just as powerful as teachers. Teachers want to discipline their students how and when they choose. This is a major dispute among parents, teachers, and students. A teacher may not ever hit a student purposely. A teacher may lower our grade for not doing work or failing class criteria. They may not lower our grade just because they donââ¬â¢t like us or we act slightly out of hand. Many people say that students donââ¬â¢t know what is best for them. This is may be true at lower elementary, but in high school, students can speak for themselves and know what they need. In some court cases or public meetings, teachers or the school bo... ...rookfield: Millbrook,1997. ââ¬Å"Student Governmentâ⬠. World Book: Millennium 2000. 2000ed. ââ¬Å"Student Rightsâ⬠. Natural Math. 21 Jan. 2002 . ââ¬Å"Students Rightsâ⬠. Rethinking Schools. Vol. 14, Issue 4 (Summer 2000). 21 Jan. 2002 . ââ¬Å"Students Rightsâ⬠. Y and M Online. 21 Jan. 2002 . ââ¬Å"Students Rights and Responsibilitiesâ⬠. University of Virginia. 21 Jan. 2002 . ââ¬Å"Students Rights Guideâ⬠. American Civil Liberties Union of Northern California. 21 Jan. 2002 . ââ¬Å"Studentsââ¬Ë Rights of Free Speechâ⬠. The American Center for Law and Justice. 20 Jan. 2002 . ââ¬Å"Students Rights on Public School Campusesâ⬠. Liberty Counsel. 20 Jan. 2002 http://www.lc.org/OldResources/Students_rights_0900.html. ââ¬Å"Teachersââ¬Ë Rights on Public School Campusesâ⬠. Liberty Counsel. 20 Jan. 2002 . Young, David. Survey. Oakridge High School: 30 Jan. 2002.
Monday, November 11, 2019
C# Step by Step Codes
SREEKANTH C# STEP BY STEP Microsoft Visual Studio C#. NET Step By Step 1 SREEKANTH C# STEP BY STEP Introduction Microsoft Visual C# is a powerful but simple language aimed primarily at developers creating applications by using the Microsoft . NET Framework. It inherits many of the best features of C++ and Microsoft Visual Basic, but few of the inconsistencies and anachronisms, resulting in a cleaner and more logical language. The advent of C# 2. 0 has seen several important new features added to the language, including Generics, Iterators, and anonymous methods.The development environment provided by Microsoft Visual Studio 2005 makes these powerful features easy to use, and the many new wizards and enhancements included in Visual Studio 2005 can greatly improve your productivity as a developer. The aim of this book is to teach you the fundamentals of programming with C# by using Visual Studio 2005 and the . NET Framework. You will learn the features of the C# language, and then use them to build applications running on the Microsoft Windows operating system.By the time you complete this book, you will have a thorough understanding of C# and will have used it to build Windows Forms applications, access Microsoft SQL Server databases, develop ASP. NET Web applications, and build and consume a Web service. Part I Introducing Microsoft Visual C# and Microsoft Visual Studio 2005 Chapter 1 Welcome to C# After completing this chapter, you will be able to: â⬠¢ â⬠¢ â⬠¢ â⬠¢ Use the Visual Studio 2005 programming environment. Create a C# console application. Use namespaces. Create a C# Windows Forms application. Microsoft Visual C# is Microsoft's powerful, component-oriented language.C# plays an important role in the architecture of the Microsoft . NET Framework, and some people have drawn comparisons to the role that C played in the development of UNIX. If you already know a language such as C, C++, or Java, you'll find the syntax of C# reassuringly fami liar because it uses the same curly brackets to delimit blocks of code. However, if you are used to programming in other languages, you should soon be able to pick up the syntax and feel of C#; you just need to learn to put the curly brackets and semi-colons in the right place. Hopefully this is just the book to help you!In Part I, you'll learn the fundamentals of C#. You'll discover how to declare variables and how to use operators such as plus (+) and minus (-) to create values. You'll see how to write methods and pass arguments to methods. You'll also learn how to use selection statements such as if and iteration statements such as while. Finally, you'll understand how C# uses exceptions to handle errors in a graceful, easy-to-use manner. These topics form the core of C#, and from this solid foundation, you'll progress to more advanced features in Part II through Part VI. 2 SREEKANTH C# STEP BY STEPBeginning Programming with the Visual Studio 2005 Environment Visual Studio 2005 i s a tool-rich programming environment containing all the functionality you'll need to create large or small C# projects. You can even create projects that seamlessly combine modules from different languages. In the first exercise, you'll start the Visual Studio 2005 programming environment and learn how to create a console application. Create a console application in Visual Studio 2005 1. In Microsoft Windows, click the Start button, point to All Programs, and then point to Microsoft Visual Studio 2005. 2.Click the Microsoft Visual Studio 2005 icon. Visual Studio 2005 starts. NOTE If this is the first time that you have run Visual Studio 2005, you might see a dialog box prompting you to choose your default development environment settings. Visual Studio 2005 can tailor itself according your preferred development language. The various dialog boxes and tools in the integrated development environment (IDE) will have their default selections set for the language you 3 SREEKANTH C# STEP BY STEP choose. Select Visual C# Development Settings from the list, and then click the Start Visual Studio button.After a short delay, the Visual Studio 2005 IDE appears. 3. On the File menu, point to New, and then click Project. The New Project dialog box opens. This dialog box allows you to create a new project using various templates, such as Windows Application, Class Library, and Console Application, that specify the type of application you want to create. NOTE The actual templates available depend on the version of Visual Studio 2005 you are using. It is also possible to define new project templates, but that is beyond the scope of this book. 4.In the Templates pane, click the Console Application icon. 5. In the Location field, type C:Documents and SettingsYourNameMy DocumentsMicrosoft PressVisual CSharp Step by StepChapter 1. Replace the text YourName in this path with your Windows user name. To save a bit of space throughout the rest of this book, we will simply refer to th e path ââ¬Å"C:Documents and SettingsYourNameMy Documentsâ⬠as your ââ¬Å"My Documentsâ⬠folder. 4 SREEKANTH C# STEP BY STEP NOTE If the folder you specify does not exist, Visual Studio 2005 creates it for you. 6. In the Name field, type TextHello. . Ensure that the Create Directory for Solution check box is checked and then click OK. The new project opens. The menu bar at the top of the screen provides access to the features you'll use in the programming environment. You can use the keyboard or the mouse to access the menus and commands exactly as you can in all Windows-based programs. The toolbar is located beneath the menu bar and provides button shortcuts to run the most frequently used commands. The Code and Text Editor window occupying the main part of the IDE displays the contents of source files.In a multi-file project, each source file has its own tab labeled with the name of the source file. You can click the tab once to bring the named source file to the foreg round in the Code and Text Editor window. The Solution Explorer displays the names of the files associated with the project, among other items. You can also double-click a file name in the Solution Explorer to bring that source file to the foreground in the Code and Text Editor window. 5 SREEKANTH C# STEP BY STEP Before writing the code, examine the files listed in the Solution Explorer, which Visual Studio 2005 has created as part of your project: Solution ââ¬ËTextHello' This is the top-level solution file, of which there is one per application. If you use Windows Explorer to look at your My DocumentsVisual CSharp Step by StepChapter 1TextHello folder, you'll see that the actual name of this file is TextHello. sln. Each solution file contains references to one or more project files. â⬠¢ TextHello This is the C# project file. Each project file references one or more files containing the source code and other items for the project. All the source code in a single project must be written in the same programming language.In Windows Explorer, this file is actually called TextHello. csproj, and it is stored in your My DocumentsVisual CSharp Step by StepChapter 1TextHelloTextHello folder. â⬠¢ Properties This is a folder in the TextHello project. If you expand it, you will see that it contains a file called AssemblyInfo. cs. AssemblyInfo. cs is a special file that you can use to add attributes to a program, such as the name of the author, the date the program was written, and so on. There are additional attributes that you can use to modify the way in which the program will run.These attributes are outside the scope of this book. â⬠¢ References This is a folder that contains references to compiled code that your application can use. When code is compiled, it is converted into an assembly and given a unique name. Developers use assemblies to package up useful bits of code that they have written for distribution to other developers that might want to use them in their applications. Many of the features that you will be using when writing applications using this book will make use of assemblies provided by Microsoft with Visual Studio 2005. â⬠¢ Program. csThis is a C# source file, and is the one displayed in the Code and Text Editor window when the project is first created. You will write your code in this file. It contains some code that Visual Studio 2005 provides automatically, which you will examine shortly. Writing Your First Program The Program. cs file defines a class called Program that contains a method called Main. All methods must be defined inside a class. The Main method is specialââ¬âit designates the program's entry point. It must be a static method. (Methods are discussed in 6 SREEKANTH C# STEP BY STEP Chapter 3, ââ¬Å"Writing Methods and Applying Scope. Static methods are discussed in Chapter 7, ââ¬Å"Creating and Managing Classes and Objects. â⬠The Main method is discussed in Chapter 11, ââ¬Å"Unde rstanding Parameter Arrays. â⬠) IMPORTANT C# is a case-sensitive language. You must spell Main with a capital M. In the following exercises, you'll write the code to display the message Hello World in the console; you'll build and run your Hello World console application; you'll learn how namespaces are used to partition code elements. Write the code using IntelliSense technology 1. In the Code and Text Editor window displaying the Program. s file, place the cursor in the Main method after the opening brace, and type Console. As you type the letter C at the start of the word Console an IntelliSense list appears. This list contains all of the valid C# keywords and data types that are valid in this context. You can either continue typing, or scroll through the list and double-click the Console item with the mouse. Alternatively, after you have typed Con, the Intellisense list will automatically home in on the Console item and you can press the Tab, Enter, or Spacebar key to selec t it. Main should look like this: static void Main(string[] args) Console } NOTE Console is a built-in class that contains the methods for displaying messages on the screen and getting input from the keyboard. 2. Type a period immediately after Console. Another Intellisense list appears displaying the methods, properties, and fields of the Console class. 3. Scroll down through the list until WriteLine is selected, and then press Enter. Alternatively, you can continue typing until WriteLine is selected and then press Enter. The IntelliSense list closes, and the WriteLine method is added to the source file. Main should now look like this: static void Main(string[] args) Console. WriteLine } 4. Type an open parenthesis. Another IntelliSense tip appears. This tip displays the parameters of the WriteLine method. In fact, WriteLine is an overloaded method, meaning that Console contains more than one method named Write Line. Each version of the WriteLine method can be used to output differ ent 7 SREEKANTH C# STEP BY STEP types of data. (Overloaded methods are discussed in Chapter 3. ) Main should now look like this: static void Main(string[] args) { Console. WriteLine( } You can click the tip's up and down arrows to scroll through the overloaded versions of WriteLine. . Type a close parenthesis, followed by a semicolon. Main should now look like this: static void Main(string[] args) { Console. WriteLine(); } 6. Type the string ââ¬Å"Hello Worldâ⬠between the left and right parentheses. Main should now look like this: static void Main(string[] args) { Console. WriteLine(ââ¬Å"Hello Worldâ⬠); } TIP Get into the habit of typing matched character pairs, such as ( and ) and { and }, before filling in their contents. It's easy to forget the closing character if you wait until after you've entered the contents. 8 SREEKANTH C# STEP BY STEP NOTEYou will frequently see lines of code containing two forward slashes followed by ordinary text. These are comments. They a re ignored by the compiler, but are very useful for developers because they help document what a program is actually doing. For example: Console. ReadLine(); // Wait for the user to press the Enter key All text from the two slashes to the end of the line will be skipped by the compiler. You can also add multi-line comments starting with /*. The compiler will skip everything until it finds a */ sequence, which could be many lines lower down.You are actively encouraged to document your code with as many comments as necessary. Build and run the console application 1. On the Build menu, click Build Solution. This action causes the C# code to be compiled, resulting in a program that you can run. The Output windows appears below the Code and Text Editor window. a. TIP If the Output window does not appear, click the View menu, and then click Output to display it. b. In the Output window, messages similar to the following show how the program is being compiled and display the details of any errors that have 9 SREEKANTH C# STEP BY STEP occurred.In this case there should be no errors or warnings, and the program should build successfully: c. ââ¬âââ¬â Build started: Project: TextHello, Configuration: Debug Any CPU ââ¬âd. Csc. exe /config /nowarn:â⬠1701;1702â⬠³ /errorreport: prompt /warn:4 â⬠¦ e. Compile complete ââ¬â- 0 errors, 0 warnings f. TextHello -> C:Documents and SettingsJohnMy DocumentsMicrosoft Pressâ⬠¦ g. ============ Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ======== h. NOTE An asterisk after the file name in the tab above the Code and Text Editor window indicates that the file has been changed since it was last saved.There is no need to manually save the file before building because the Build Solution command automatically saves the file. 2. On the Debug menu, click Start Without Debugging. A Command window opens and the program runs. The message Hello World appears, and then the program waits for the user to press any key, as shown in the following graphic: 3. Ensure that the Command window displaying the program has the focus, and then press Enter. The Command window closes and you return to the Visual Studio 2005 programming environment. NOTE If you run the program using Start Debugging on the Debug menu, the pplication runs but the Command window closes immediately without waiting for you to press a key. 4. In the Solution Explorer, click the TextHello project (not the solution), and then click Show All Files button. Entries named bin and obj appear above the C# source filenames. These entries correspond directly to folders named bin and obj in the project folder (My DocumentsVisual CSharp Step by StepChapter 1TextHelloTextHello). These folders are created when you build your application, and they contain the executable version of the program and some other files. 10 SREEKANTHC# STEP BY STEP 5. 5. In the Solution Explorer, click the + to the left of the bin entry. Another folder named Deb ug appears. 6. 6. In the Solution Explorer, click the + to the left of the Debug entry. Three entries named TextHello. exe, TextHello. pdb, and TextHello. vshost. exe appear. The file TextHello. exe is the compiled program, and it is this file that runs when you click Start Without Debugging in the Debug menu. The other two files contain information that is used by Visual Studio 2005 if you run your program in Debug mode (when you click Start Debugging in the Debug menu).Command Line Compilation You can also compile your source files into an executable file manually by using the csc command-line C# compiler. You must first complete the following steps to set up your environment: 1. On the Windows Start menu, point to All Programs, point to Microsoft Visual Studio 2005, point to Visual Studio Tools, and click Visual Studio 2005 Command Prompt. A Command window opens, and the envionment variables PATH, LIB, and INCLUDE are configured to include the locations of the various . NET Frame work libraries and utilities. TIP You can also run the vcvarsall. at script, located in the C:Program FilesMicrosoft Visual Studio 8VC folder, if you want to configure the environment variables while running in an ordinary Command Prompt window. 2. In the Visual Studio 2005 Command Prompt window, type the following command to go to the My DocumentsMicrosoft PressVisual CSharp Step by StepChapter 1TextHelloTextHello project folder: 3. cd Documents and SettingsYourNameMy DocumentsMicrosoft PressVisual CSharp Step by StepChapter 1TextHelloTextHello 4. Type the following command: csc /out:TextHello. exe Program. cs 11 SREEKANTH C# STEP BY STEPThis command creates the executable file TextHello. exe from the C# source file. If you don't use the /out command-line option, the executable file takes its name from the source file and is called Program. exe. 5. Run the program by typing the following command: TextHello The program should run exactly as before, except that you will not see the à ¢â¬Å"Press any key to continueâ⬠prompt. Using Namespaces The example you have seen so far is a very small program. However, small programs can soon grow into bigger programs. As a program grows, it creates two problems. First, more code is harder to understand and maintain than less code.Second, more code usually means more names; more named data, more named methods, and more named classes. As the number of names increases so does the likelihood of the project build failing because two or more names clash (especially when the program uses third-party libraries). In the past, programmers tried to solve the name-clashing problem by prefixing names with some sort of qualifier (or set of qualifiers). This solution is not a good one because it's not scalable; names become longer and you spend less time writing software and more time typing (there is a difference) and reading and re-reading incomprehensibly long names.Namespaces help solve this problem by creating a named container for other identifiers, such as classes. Two classes with the same name will not be confused with each other if they live in different namespaces. You can create a class named Greeting inside the namespace named TextHello, like this: namespace TextHello { class Greeting { â⬠¦ } } You can then refer to the Greeting class as TextHello. Greeting in your own programs. If someone else also creates a Greeting class in a different namespace and installs it on your computer, your programs will still work as expected because they are using the TextHello.Greeting class. If you want to refer the new Greeting class, you must specify that you want the class from the new namespace. It is good practice to define all your classes in namespaces, and the Visual Studio 2005 environment follows this recommendation by using the name of your project as the toplevel namespace. The . NET Framework Software Developer Kit (SDK) also adheres to this recommendation; every class in the . NET Framework lives inside a namespace. For 12 SREEKANTH C# STEP BY STEP example, the Console class lives inside the System namespace. This means that its fully qualified name is actually System.Console. Of course, if you had to write the fully qualified name of a class every time, it would be no better that just naming the class SystemConsole. Fortunately, you can solve this problem with a using directive. If you return to the TextHello program in Visual Studio 2005 and look at the file Program. cs in the Code and Text Editor window, you will notice the following statements: using System; using System. Collections. Generic; using System. Text; The using statement brings a namespace into scope, and you no longer have to explictly qualify objects with the namespace they belong to in the code that follows.The three namespaces shown contain classes that are used so often that Visual Studio 2005 automatically adds these using statements every time you create a new project. You can add further using direct ives to the top of a source file. The following exercise demonstrates the concept of namespaces further. Try longhand names 1. In the Code And Text Editor window, comment out the using directive at the top of Program. cs: //using System; 2. On the Build menu, click Build Solution. The build fails, and the Output pane displays the following error message twice (once for each use of the Console class):The name ââ¬ËConsole' does not exist in the current context. 3. In the Output pane, double-click the error message. The identifier that caused the error is selected in the Program. cs source file. TIP The first error can affect the reliability of subsequent diagnostic messages. If your build has more than one diagnostic message, correct only the first one, ignore all the others, and then rebuild. This strategy works best if you keep your source files small and work iteratively, building frequently. 4. In the Code and Text Editor window, edit the Main method to use the fully qualified name System. Console.Main should look like this: static void Main(string[] args) { System. Console. WriteLine(ââ¬Å"Hello Worldâ⬠); 13 SREEKANTH C# STEP BY STEP } NOTE When you type System. , notice how the names of all the items in the System namespace are displayed by IntelliSense. 5. On the Build menu, click Build Solution. The build succeeds this time. If it doesn't, make sure Main is exactly as it appears in the preceding code, and then try building again. 6. Run the application to make sure it still works by clicking Start Without Debugging on the Debug menu. In the Solution Explorer, click the + to the left of the References entry.This displays the assemblies referenced by the Solution Explorer. An assembly is a library containing code written by other developers (such as the . NET Framework). In some cases, the classes in a namespace are stored in an assembly that has the same name (such as System), although this does not have to be the caseââ¬âsome assemblies hold more than one namespace. Whenever you use a namespace, you also need to make sure that you have referenced the assembly that contains the classes for that namespace; otherwise your program will not build (or run). Creating a Windows Forms ApplicationSo far you have used Visual Studio 2005 to create and run a basic Console application. The Visual Studio 2005 programming environment also contains everything you'll need to create graphical Windows applications. You can design the form-based user interface of a Windows application interactively by using the Visual Designer. Visual Studio 2005 then generates the program statements to implement the user interface you've designed. From this explanation, it follows that Visual Studio 2005 allows you to maintain two views of the application: the Design View and the Code View.The Code and Text Editor window (showing the program statements) doubles as the Design View window (allowing you to lay out your user interface), and you can switch bet ween the two views whenever you want. In the following set of exercises, you'll learn how to create a Windows program in Visual Studio 2005. This program will display a simple form containing a text box where you can enter your name and a button that, when clicked, displays a personalized greeting in a message box.You will use the Visual Designer to create your user interface by placing controls on a form; inspect the code generated by Visual Studio 2005; use the Visual Designer to change the control properties; use the Visual Designer to resize the form; write the code to respond to a button click; and run your first Windows program. Create a Windows project in Visual Studio 2005 1. On the File menu, point to New, and then click Project. The New Project dialog box opens. 2. In the Project Types pane, click Visual C#. 14 SREEKANTH C# STEP BY STEP 3. In the Templates pane, click the Windows Application icon. . Ensure that the Location field refers to your My DocumentsVisual CSharp St ep by StepChapter 1 folder. 5. In the Name field, type WinFormHello. 6. In the Solutions field, ensure that Create new Solution is selected. This action creates a new solution for holding the Windows application. The alternative, Add to Solution, will add the project to the TextHello solution. 7. Click OK. Visual Studio 2005 closes your current application (prompting you to save it first of necessary) and creates and displays an empty Windows form in the Design View window.In the following exercise, you'll use the Visual Designer to add three controls to the Windows form and examine some of the C# code automatically generated by Visual Studio 2005 to implement these controls. Create the user interface 1. Click the Toolbox tab that appears to the left of the form in the Design View. The Toolbox appears, partially obscuring the form and displaying the various components and controls that you can place on a Windows form. 2. In the Toolbox, click the + sign by Common Controls to display a list of controls that are used by most Windows Forms applications. 15 SREEKANTHC# STEP BY STEP 3. Click Label, and then click the visible part of the form. A Label control is added to the form, and the Toolbox disappears from view. TIP If you want the Toolbox to remain visible but not hide any part of the form, click the Auto Hide button to the right in Toolbox title bar (it looks like a pin). The Toolbox appears permanently on the left side of the Visual Studio 2005 window, and the Design View shrinks to accommodate it. (You might lose a lot of space if you have a low-resolution screen. ) Clicking the Auto Hide button once more causes the Toolbox to disappear again. 4.The Label control on the form is probably not exactly where you want it. You can click and drag the controls you have added to a form to reposition them. Using this technique, move the Label control so that it is positioned towards the upper-left corner of the form. (The exact placement is not critical for this app lication. ) 5. On the View menu, click Properties Window. The Properties window appears on the right side of the screen. The Properties window allows you to set the properties for items in a project. It is context sensitive, in that it displays the properties for the currently selected item.If you click anywhere on the form displayed in the Design View, you will see that the Properties windows displays the properties for the form itself. If you click the Label control, the window displays the properties for the label instead. 6. Click the Label control on the form. In the Properties window, locate the Text property, change it from label1 to Enter your name, and then press Enter. On the form, the label's text changes to Enter Your Name. TIP By default, the properties are displayed in categories. If you prefer to display the properties in alphabetical order, click the Alphabetical button that appears above the properties list. . Display the Toolbox again. Click TextBox, and then click the form. A TextBox control is added to the form. Move the TextBox control so that it is directly underneath the Label control. TIP When you drag a control on a form, alignment handles appear automatically when the control becomes aligned vertically or horizontally with other controls. This give you a quick visual cue for making sure that controls are lined up neatly. 8. While the TextBox control is selected, locate the Text property in the Properties window, type here, and then press Enter. On the form, the word here appears in the text box. 9.In the Properties window, find the (Name) property. Visual Studio 2005 gives controls and forms default names, which, although they are a good starting point, are not always very meaningful. Change the name of the TextBox control to userName. 16 SREEKANTH C# STEP BY STEP NOTE We will talk more about naming conventions for controls and variables in Chapter 2, ââ¬Å"Working with Variables, Operators, and Expressions. â⬠10. Display the T oolbox again, click Button, and then click the form. Drag the Button control to the right of the TextBox control on the form so that it is aligned horizontally with the text box. 11.Using the Properties window, change the Text property of the Button control to OK. Change its (Name) property to ok. The caption on the button changes. 12. Click the Form1 form in the Design View window. Notice that resize handles (small squares) appear on the lower edge, the right-hand edge, and the righthand bottom corner of the form. 13. Move the mouse pointer over the resize handle. The pointer changes to a diagonal double-headed arrow. 14. Hold down the left mouse button, and drag the pointer to resize the form. Stop dragging and release the mouse button when the spacing around the controls is roughly equal.TIP You can resize many controls on a form by selecting the control and dragging one of the resize handles that appears in the corners of the control. Note that a form has only one resize handle, whereas most controls have four (one on each corner). On a form, any resize handles other than the one in the lower-right corner would be superfluous. Also note that some controls, such as Label controls, are automatically sized based on their contents and cannot be resized by dragging them. The form should now look similar to the one in the following graphic. 1. In the Solution Explorer, right-click the file Form1. s, and then click View Code. The Form1. cs source file appears in the Code and Text Editor window. There are now two tabs named Form1. cs above the Code and Text Editor/Design View window. You can click the one suffixed with [Design] to return to Design View window at any time. Form1. cs contains some of the code automatically generated by Visual Studio 2005. You should note the following elements: 17 SREEKANTH C# STEP BY STEP o using directives Visual Studio 2005 has written a number of using directives at the top of the source file (more than for the previous example) . For example: using System. Windows. Forms;The additional namespaces contain the classes and controls used when building graphical applicationsââ¬âfor example, the TextBox, Label, and Button classes. o The namespace Visual Studio 2005 has used the name of the project as the name of the toplevel namespace: namespace WinFormHello { â⬠¦ } o A class Visual Studio 2005 has written a class called Form1 inside the WinForm Hello namespace: namespace WinFormHello { partial class Form1 â⬠¦ { â⬠¦ } } NOTE For the time being, ignore the partial keyword in this class. I will describe its purpose shortly. This class implements the form you created in the Design View. Classes are discussed in Chapter 7. ) There does not appear to be much else in this classââ¬âthere is a little bit of code known as a constructor that calls a method called InitializeComponent, but nothing else. (A constructor is a special method with the same name as the class. It is executed when the form is cr eated and can contain code to initialize the form. Constructors are also discussed in Chapter 7. ) However, Visual Studio 2005 is performing a sleight of hand and is hiding a few things from you, as I will now demonstrate. In a Windows Forms application, Visual Studio 2005 actually generates a potentially large amount of code.This code performs operations such as 18 SREEKANTH C# STEP BY STEP creating and displaying the form when the application starts, and creating and positioning the various controls on the form. However, this code can change as you add controls to a form and change their properties. You are not expected to change this code (indeed, any changes you make are likely to be overwritten the next time you edit the form in the Design View), so Visual Studio 2005 hides it from you. To display the hidden code, return to the Solution Explorer, and click the Show All Files button.The bin and obj folders appear, much as they did with the Console application you developed in th e first part of this chapter. However, notice that Form1. cs now has a + sign next to it. If you click this + sign, you see a file called Form1. Designer. cs, and a file called Form1. resx. Double-click the file Form1. Designer. cs to display its contents in the Code and Text Editor window. You will see the remaining code for the Form1 class in this file. C# allows you to split the code for a class across multiple source files, as long as each part of the class is marked with the partial keyword.This file includes a region labelled Windows Form Designer generated code. Expanding this region by clicking the + sign reveals the code created and maintained by Visual Studio 2005 when you edit a form using the Design View window. The actual contents of this file include: o The InitializeComponent method This method is mentioned in the file Form1. cs. The statements inside this method set the properties of the controls you added to the form in the Design View. (Methods are discussed in Cha pter 3. ) Some of the statements in this method that correspond to the actions you performed using the Properties window are shown below: .. private void InitializeComponent() { this. label1 = new System. Windows. Forms. Label(); this. userName = new System. Windows. Forms. TextBox(); this. ok = new System. Windows. Forms. Button(); â⬠¦ this. label1. Text = ââ¬Å"Enter your nameâ⬠; â⬠¦ this. userName. Text = ââ¬Å"hereâ⬠; â⬠¦ this. ok. Text = ââ¬Å"OKâ⬠; â⬠¦ } â⬠¦ o Three fields Visual Studio 2005 has created three fields inside the Form1 class. These fields appear near the end of the file: private System. Windows. Forms. Label label1; 19 SREEKANTH C# STEP BY STEP private System. Windows. Forms. TextBox userName; private System. Windows. Forms. Button ok; .. These fields implement the three controls you added to the form in Design View. (Fields are discussed in Chapter 7. ) It is worth restating that although this file is interesting to look at, you should never edit its contents yourself. Visual Studio 2005 automatically updates this file when you make changes in the Design View. Any code that you need to write yourself should be placed in the Form1. cs file. At this point you might well be wondering where the Main method is and how the form gets displayed when the application runs; remember that Main defines the point at which the program starts.In the Solution Explorer, you should notice another source file called Program. cs. If you double-click this file the following code appears in the Code and Text Editor window: namespace WinFormHello { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application. EnableVisualStyles(); Application. Run(new Form1()); } } } You can ignore most of this code. However, the key statement is: Application. Run(new Form1()); This statement creates the form and displays it, whereupon the form takes over. In the following exercise, you'll learn how to add code that runs when he OK button on the form is clicked. Write the code for the OK button 1. Click the Form1. cs[Design] tab above the Code and Text Editor window to display Form1 in the Design View. 2. Move the mouse pointer over the OK button on the form, and then double-click the button. The Form1. cs source file appears in the Code and Text Editor window. Visual Studio 2005 has added a method called ok_Click to the Form1 class. (It has also added a statement to the InitializeComponent method in the Form1. Designer. cs file to automatically call ok_Click when the OK button is 20 SREEKANTH C# STEP BY STEP clicked.It does this by using a delegate type; delegates are discussed in Chapter 16, ââ¬Å"Delegates and Events. â⬠) 3. Type the MessageBox statement shown below inside the ok_Click method. The complete method should look like this: 4. private void ok_Click(object sender, System. EventArgs e) 5. { 6. MessageBox. Show(ââ¬Å"Hello â⬠+ userName . Text); } Make sure you have typed this code exactly as shown, including the trailing semicolon. You're now ready to run your first Windows program. Run the Windows program 1. On the Debug menu, click Start Without Debugging. Visual Studio 2005 saves your work, compiles your program, and runs it.The Windows form appears: 2. Enter your name, and then click OK. A message box appears welcoming you by name. 3. Click OK in the message box. The message box closes. 4. In the Form1 window, click the Close button (the X in the upper-right corner of the form). The Form1 window closes. â⬠¢ If you want to continue to the next chapter Keep Visual Studio 2005 running, and turn to Chapter 2. â⬠¢ If you want to exit Visual Studio 2005 now On the File menu, click Exit. If you see a Save dialog box, click Yes to save your work. Chapter 1 Quick Reference TO Do this KeyCombination 21 SREEKANTH C# STEP BY STEP Create a onsole application new On the File menu, point to New, and then click Projec t to open the New Project dialog box. For the project type, select Visual C#. For the template, select Console Application. Select a directory for the project files in the Location box. Choose a name for the project. Click OK. Create a Windows application new On the File menu, point to New, and then click Project to open the New Project dialog box. For the project type, select Visual C#. For the template, select Windows Application. Select a directory for the project files in the location box. Choose a name for the project.Click OK. Build application F6 the On the Build menu, click Build Solution. Ctrl+F5 Chapter 2 Working with Variables, Operators, and Expressions After completing this chapter, you will be able to: â⬠¢ â⬠¢ â⬠¢ â⬠¢ â⬠¢ Understand statements, identifiers, and keywords. Use variables to store information. Work with primitive data types. Use arithmetic operators such as the plus sign (+) and the minus sign (ââ¬â). Increment and decrement variabl es. In Chapter 1, ââ¬Å"Welcome to C#,â⬠you learned how to use the Microsoft Visual Studio 2005 programming environment to build and run a console program and a Windows Forms application.In this chapter, you'll be introduced to the elements of Microsoft Visual C# syntax and semantics, including statements, keywords, and identifiers. You'll study the primitive types that are built into the C# language and the characteristics of the values that each type holds. You'll also see how to declare and use local variables (variables that exist only within a function or other small section of code), learn about the arithmetic operators that C# provides, learn how to use operators to manipulate values, and learn how to control expressions containing two or more operators. Understanding StatementsA statement is a command that performs an action. Statements are found inside methods. You'll learn more about methods in Chapter 3, ââ¬Å"Writing Methods and Applying Scope,â⬠but for now , think of a method as a named sequence of statements inside a class. Main, which was introduced in the previous chapter, is an example of a method. Statements in C# must follow a well-defined set of rules. These rules are collectively known as syntax. (In contrast, the specification of what statements do is collectively known as semantics. ) One of the simplest and most important C# syntax rules states 22 SREEKANTH C# STEP BY STEP hat you must terminate all statements with a semicolon. For example, without its terminating semicolon, the following statement won't compile: Console. WriteLine(ââ¬Å"Hello Worldâ⬠); TIP C# is a ââ¬Å"free formatâ⬠language, which means that white space, such as a space character or a new line, is not significant except as a separator. In other words, you are free to lay out your statements in any style you choose. A simple, consistent layout style makes a program easier to read and understand. The trick to programming well in any language is learning its syntax and semantics and then using the language in a natural and idiomatic way.This approach makes your programs readable and easy to modify. In the chapters throughout this book, you'll see examples of the most important C# statements. Using Identifiers Identifiers are the names you use to identify the elements in your programs. In C#, you must adhere to the following syntax rules when choosing identifiers: â⬠¢ â⬠¢ You can use only letters (uppercase and lowercase), digits, and underscore characters. An identifier must start with a letter (an underscore is considered a letter). For example, result, _score, footballTeam, and plan9 are all valid identifiers, whereas result%, footballTeam$, and 9plan are not.IMPORTANT C# is a case-sensitive language: footballTeam and FootballTeam are not the same identifier. Identifying Keywords The C# language reserves 77 identifiers for its own use, and you should not reuse these identifiers for your own purposes. These identi fiers are called keywords, and each has a particular meaning. Examples of keywords are class, namespace, and using. You'll learn the meaning of most of the keywords as you proceed through this book. The keywords are listed in the following table. abstract break char continue do event finally foreach in is as byte checked decimal double explicit fixed goto int ock base case class default else extern float if interface long 23 bool catch const delegate enum false for implicit internal namespace SREEKANTH new out protected return sizeof struct true ulong using while C# STEP BY STEP null override public sbyte stackalloc switch try unchecked virtual object params readonly sealed static this typeof unsafe void operator private ref short string throw uint ushort volatile TIP In the Visual Studio 2005 Code and Text Editor window, keywords are colored blue when you type them. TIP In the Visual Studio 2005 Code and Text Editor window, keywords are colored blue when you type them.Using Variabl es A variable is a storage location that holds a value. You can think of a variable as a box holding temporary information. You must give each variable in a program a unique name. You use a variable's name to refer to the value it holds. For example, if you want to store the value of the cost of an item in a store, you might create a variable simply called cost, and store the item's cost in this variable. Later on, if you refer to the cost variable, the value retrieved will be the item's cost that you put there earlier. Naming VariablesYou should adopt a naming convention for variables that help you avoid confusion concerning the variables you have defined. The following list contains some general recommendations: â⬠¢ â⬠¢ Don't use underscores. Don't create identifiers that differ only by case. For example, do not create one variable named myVariable and another named MyVariable for use at the same time, because it is too easy to get them confused. NOTE Using identifiers tha t differ only by case can limit the ability to reuse classes in applications developed using other languages that are not case sensitive, such as Visual Basic. â⬠¢ â⬠¢ â⬠¢ Start the name with a lowercase letter.In a multiword identifier, start the second and each subsequent word with an uppercase letter. (This is called camelCase notation. ) Don't use Hungarian notation. (Microsoft Visual C++ developers reading this book are probably familiar with Hungarian notation. If you don't know what Hungarian notation is, don't worry about it! ) 24 SREEKANTH C# STEP BY STEP IMPORTANT You should treat the first two recommendations as compulsory because they relate to Common Language Specification (CLS) compliance. If you want to write programs that can interoperate with other languages, such as Microsoft Visual Basic .NET, you need to comply with these recommendations. For example, score, footballTeam, _score, and FootballTeam are all valid variable names, but only the first two ar e recommended. Declaring Variables Remember that variables are like boxes in memory that can hold a value. C# has many different types of values that it can store and processââ¬âintegers, floating-point numbers, and strings of characters, to name three. When you declare a variable, you must specify what type of data it will hold. NOTE Microsoft Visual Basic programmers should note that C# does not allow implicit declarations.You must explicitly declare all variables before you can use them if you want your code to compile. You declare the type and name of a variable in a declaration statement. For example, the following statement declares that the variable named age holds int (integer) values. As always, the statement must be terminated with a semi-colon. int age; The variable type int is the name of one of the primitive C# typesââ¬âinteger which is a whole number. (You'll learn about several primitive data types later in this chapter. ) After you've declared your variable, you can assign it a value. The following statement assigns age the value 42.Again, you'll see that the semicolon is required. age = 42; The equal sign (=) is the assignment operator, which assigns the value on its right to the variable on its left. After this assignment, the age variable can be used in your code to refer to the value it holds. The next statement writes the value of the age variable, 42, to the console: Console. WriteLine(age); TIP If you leave the mouse pointer over a variable in the Visual Studio 2005 Code and Text Editor window, a ToolTip appears telling you the type of the variable. Working with Primitive Data Types C# has a number of built-in types called primitive data types.The following table lists the most commonly used primitive data types in C#, and the ranges of values that you can store in them. 25 SREEKANTH C# STEP BY STEP Data type int Description Size (bits) *Range Sample usage Whole numbers 32 int count; count = 42; long Whole numbers (bigger range) 64 float Floating-point numbers 32 231 through 2311 263 through 2631 à ±3. 4 ? 1038 double Double accurate) numbers decimal Monetary values 128 string Sequence of characters 16 bits per Not applicable character char Single character 16 bool Boolean 8 precision (more 64 floating-point à ±1. 7 ? 10308 28 significant igures long wait; wait = 42L; float away; away = 0. 42F; double trouble; trouble = 0. 42; decimal coin; coin = 0. 42M; string vest; vest = ââ¬Å"42â⬠; char grill; grill = ââ¬Ë4'; 0 through 216 1 bool teeth; true or false teeth false; = *The value of 216 is 32,768; the value of 231 is 2,147,483,648; and the value of 263 is 9,223,372,036,854,775,808. Unassigned Local Variables When you declare a variable, it contains a random value until you assign a value to it. This behavior was a rich source of bugs in C and C++ programs that created a variable and used it as a source of information before giving it a value.C# does not allow you to use an unassigned variable. Y ou must assign a value to a variable before you can use it, otherwise your program will not compile. This requirement is called the Definite Assignment Rule. For example, the following statements will generate a compile-time error because age is unassigned: int age; Console. WriteLine(age); // compile time error Displaying Primitive Data Type Values In the following exercise, you'll use a C# program named PrimitiveDataTypes to demonstrate how several primitive data types work. Display primitive data type values 26SREEKANTH C# STEP BY STEP 1. Start Visual Studio 2005. 2. On the File menu, point to Open, and then click Project/Solution. The Open Project dialog box appears. 3. Move to the Microsoft PressVisual CSharp Step by StepChapter 2PrimitiveDataTypes folder in your My Documents folder. Select the file PrimitiveDataTypes. sln and then click Open. The solution loads, and the PrimitiveDataTypes project. Solution Explorer displays the solution and NOTE Solution file names have the . sln suffix, such as PrimitiveDataTypes. sln. A solution can contain one or more projects.Project files have the . csproj suffix. If you open a project rather than a solution, Visual Studio 2005 will automatically create a new solution file for it. If you build the solution, Visual Studio 2005 automatically saves any updated or new files, and you will be prompted to provide a name and location for the new solution file. 4. On the Debug menu, click Start Without Debugging. The following application window appears: 5. In the Choose A Data type list, click the string type. The value 42 appears in the Sample value box. 6. Click the int type in the list.The value to do appears in the Sample value box, indicating that the statements to display an int value still need to be written. 27 SREEKANTH C# STEP BY STEP 7. Click each data type in the list. Confirm that the code for the double and bool types also needs to be completed. 8. Click Quit closing the window and stopping the program. Contro l returns to the Visual Studio 2005 programming environment. Use primitive data types in code 1. Right-click the Form1. cs file in the Solution Explorer and then click View Code. The Code and Text Editor window opens displaying the Form1. cs file. 2.In the Code and Text Editor window, find the show Float Value method listed here: private void showFloatValue() { float var; var = 0. 42F; value. Text = ââ¬Å"0. 42Fâ⬠; } TIP To locate an item in your project, point to Find And Replace on the Edit menu and click Quick Find. A dialog box opens asking what you want to search for. Type the name of the item you're looking for, and then click Find Next. By default, the search is not case-sensitive. If you want to perform a case-sensitive search, click the + button next to the Find Options label to display additional options, and check the Match Case check box.If you have time, you can experiment with the other options as well. You can also press Ctrl+F (press the Control key, and then p ress F) to display the Quick Find dialog box rather then usin g the Edit menu. Similarly, you can press Ctrl+H to display the Quick Find and Replace dialog box. The showFloatValue method runs when you click the float type in the list box. This method contains three statements: The first statement declares a variable named var of type float. The second statement assigns var the value 0. 42F. (The F is a type suffix specifying that 0. 2 should be treated as a float value. If you forget the F, the value 0. 42 will be treated as a double, and your program will not compile because you cannot assign a value of one type to a variable of a different type in this way. ) The third statement displays the value of this variable in the value TextBox on the form. This statement requires a little bit of your attention. The way in which you display an item in a TextBox is to set its Text property. You did this at 28 SREEKANTH C# STEP BY STEP design time in Chapter 1 using the Properties window. Thi s statement shows ou how to perform the same task programmatically, using the expression value. Text. The data that you put in the Text property must be a string (a sequence of characters), and not a number. If you try and assign a number to the Text property your program will not compile. For this reason, the statement simply displays the text ââ¬Å"0. 42Fâ⬠in the TextBox (anything in double-quotes is text, otherwise known as a string). In a real-world application, you would add statements that convert the value of the variable var into a string and then put this into the Text property, but you need to know a little bit more about C# and the .NET Framework before we can do that (we will cover data type conversions in Chapter 11, ââ¬Å"Understanding Parameter Arrays,â⬠and Chapter 19, ââ¬Å"Operator Overloadingâ⬠). 3. In the Code and Text Editor window, locate the showIntValue method listed here: private void showIntValue() { value. Text = ââ¬Å"to doâ⬠; } T he showIntValue method is called when you click the int type in the list box. TIP Another way to find a method in the Code and Text Editor window is to click the Members list that appears above the window, to the right. This window displays a list of all the methods (and other items).You can click the name of a member, and you will be taken directly to it in the Code and Text Editor window. 4. Type the following two statements at the start of the showIntValue method, after the open curly brace: int var; var = 42; The showIntValue method should now look like this: private void showIntValue() { int var; var = 42; value. Text = ââ¬Å"to doâ⬠; } 5. On the Build menu, click Build Solution. a. The build will display some warnings, but no errors. You can ignore the warnings for now. 6. In the original statement, change the string ââ¬Å"to doâ⬠to ââ¬Å"42â⬠. b. The method should now look exactly like this: 9 SREEKANTH C# STEP BY STEP c. private void showIntValue() d. { i. int var; ii. var = 42; iii. value. Text = ââ¬Å"42â⬠; e. } 7. On the Debug menu, click Start Without Debugging. f. The form appears again. g. TIP If you have edited the source code since the last build, the Start Without Debugging command automatically rebuilds the program before starting the application. 8. Select the int type in the list box. Confirm that the value 42 is displayed in the Sample value text box. 9. Click Quit to close the window and stop the program. 10. In the Code and Text Editor window, find the showDoubleValue method. 1. Edit the showDoubleValue method exactly as follows: private void showDoubleValue() { double var; var = 0. 42; value. Text = ââ¬Å"0. 42â⬠; } 12. In the Code and Text Editor window, locate the showBoolValue method. 13. Edit the showBoolValue method exactly as follows: private void showBoolValue() { bool var; var = false; value. Text = ââ¬Å"falseâ⬠; } 14. On the Debug menu, click Start Without Debugging. The form appears. 15. I n the list, select the int, double, and bool types. In each case, verify that the correct value is displayed in the Sample value text box. 16. Click Quit to stop the program.Using Arithmetic Operators C# supports the regular arithmetic operations you learned in your childhood: the plus sign (+) for addition, the minus sign (ââ¬â) for subtraction, the asterisk (*) for multiplication, and the forward slash (/) for division. These symbols (+, ââ¬â, *, and /) are called operators as they ââ¬Å"operateâ⬠on values to create new values. In the following 30 SREEKANTH C# STEP BY STEP example, the variable moneyPaidToConsultant ends up holding the product of 750 (the daily rate) and 20 (the number of days the consultant was employed): long moneyPaidToConsultant; oneyPaidToConsultant = 750 * 20; NOTE The values that an operator operates on are called operands. In the expression 750 * 20, the * is the operator, and 750 and 20 are the operands. Determining an Operator's Values Not all operators are applicable to all data types, so whether you can use an operator on a value depends on the value's type. For example, you can use all the arithmetic operators on values of type char, int, long, float, double, or decimal. However, with one exception, you can't use the arithmetic operators on values of type string or bool.So the following statement is not allowed because the string type does not support the minus operator (subtracting one string from another would be meaningless): // compile time error Console. WriteLine(ââ¬Å"Gillinghamâ⬠ââ¬â ââ¬Å"Manchester Cityâ⬠); The exception is that the + operator can be used to concatenate string values. The following statement writes 431 (not 44) to the console: Console. WriteLine(ââ¬Å"43â⬠+ ââ¬Å"1â⬠); TIP You can use the method Int32. Parse to convert a string value to an integer if you need to perform arithmetic computations on values held as strings.You should also be aware that the type of the result of an arithmetic operation depends on the type of the operands used. For example, the value of the expression 5. 0 / 2. 0 is 2. 5; the type of both operands is double (in C#, literal numbers with decimal points are always double, not float, in order to maintain as much accuracy as possible), and so the type of the result is also double. However, the value of the expression 5 / 2 is 2. In this case, the type of both operands is int, and so the type of the result is also int. C# always rounds values down in circumstances like this.The situation gets a little more complicated if you mix the types of the operands. For example, the expression 5 / 2. 0 consists of an int and a double. The C# compiler detects the mismatch and generates code that converts the int into a double before performing the operation. The result of the operation is therefore a double (2. 5). However, although this works, it is considered poor practice to mix types in this way. C# also supports one less -familiar arithmetic operator: the remainder, or modulus, operator, which is represented by the percent symbol (%). The result of x % y is the remainder after dividing x by y.For example, 9 % 2 is 1 since 9 divided by 2 is 8, remainder 1. NOTE In C and C++, you can't use the % operator on floating-point values, but you can use it in C#. Examining Arithmetic Operators 31 SREEKANTH C# STEP BY STEP The following exercise demonstrates how to use the arithmetic operators on int values using a previously written C# program named MathsOperators. Work with arithmetic operators 1. On the File menu, point to Open, and then click Project/Solution. Open the MathsOperators project, located in the Microsoft PressVisual CSharp Step by StepChapter 2MathsOperators folder in your My Documents folder. . On the Debug menu, click Start Without Debugging. A form appears on the screen. 3. Type 54 in the left operand text box. 4. Type 13 in the right operand text box. You can now apply any of the operators to the values in the text boxes. 5. Click the ââ¬â Subtraction option, and then click Calculate. The text in the Expression box changes to 54 ââ¬â 13, and 41 appears in the Result box, as shown in the following graphic: 6. Click the / Division option, and then click Calculate. The text in the Expression text box changes to 54 / 13, and the number 4 appears in the Result box. In real life, 54 / 13 is 4. 53846 recurring, but this is not real life; this is C#! In C#, when you divide one integer by another integer, the answer you get back is an integer, as explained earlier. 32 SREEKANTH C# STEP BY STEP 7. Select the % Remainder option, and then click Calculate. The text in the Expression text box changes to 54 % 13, and the number 2 appears in the Result box. This is because the remainder after dividing 54 by 13 is 2 (54 ââ¬â ((54 / 13) * 13) is 2 if you do the arithmetic rounding down to an integer at each stageââ¬âmy old maths master at school would be horrified to b e told that (54 / 13) * 13 does not equal 54! . 8. Practice with other combinations of numbers and operators. When you're finished, click Quit. The program stops, and you return to the Visual Studio 2005 programming environment. Now take a look at the MathsOperators program code. Examine the MathsOperators program code 1. Display the Form1 form in the Design View window (click the Form1. cs[Design] tab if necessary). TIP You can quickly switch between the Design View window and the Code and Text Editor displaying the code for a form by pressing the F7 key. 2. In the View menu, point to Other Windows and then click Document Outline.The Document Outline window appears showing the names and types of the controls on the form. If you click each of the controls on the form, the name of the control is highlighted in the Document Outline window. 33 SREEKANTH C# STEP BY STEP IMPORTANT Be careful not to accidentally delete or change the names of any controls on the form while viewing them in the Document Outline window. The application will no longer work if you do. 3. Click the the two TextBox controls that the user types numbers into on the form. In the Document Outline window, verify that they are named lhsOperand and rhsOperand.When the form runs, the Text property of each of these controls holds (as strings) the numeric values you enter. 4. Towards the bottom of the form, verify that the TextBox control used to display the expression being evaluated is named expression, and that the TextBox control used to display the result of the calculation is named result. At runtime, setting the Text property of a TextBox control to a string value causes that value to be displayed. 5. Close the Document Outline window. 6. Press F7 to display the Form1. cs source file in the Code and Text Editor window. 7.In the Code and Text Editor window, locate the subtractValues method: private void subtractValues() { int lhs = int. Parse(lhsOperand. Text); int rhs = int. Parse(rhsOperand. Text); int outcome; outcome = lhs ââ¬â rhs; expression. Text = lhsOperand. Text + â⬠ââ¬â â⬠+ rhsOperand. Text; result. Text = outcome. ToString(); } The first statement in this method declares an int variable called lhs and initializes it to the result of the explicit conversion of the lhsOperand. Text property to an int. (The Text property of a TextBox is a string, and must be converted to an integer before you can store it in an int. This is what the int.Parse method does) The second statement declares an int variable called rhs and initializes it to the result of the explicit conversion of the rhsOperand. Text property to an int. The third statement declares an int variable called outcome. The fourth statement subtracts the value of the rhs variable from the value of the lhs variable, and the result is assigned to outcome. The fifth statement concatenates three strings (using the + operator) and assigns the result to the expression. Text property. The sixth st atement converts the int value of outcome to a string by using the ToString method, and assigns the string to the result.Text property. 34 SREEKANTH C# STEP BY STEP The Text Property and the ToString Method I mentioned earlier that TextBox controls displayed on a form have a Text property that allows you to access the displayed contents. For example, the expression result. Text refers to the contents of the result text box on the form. Text boxes also have many other properties, such as the location and size of the text box on the form. You will learn more about properties in Chapter 14, ââ¬Å"Implementing Properties to Access Attributes. â⬠Every class has a ToString method.The purpose of ToString is to convert an object into its string representation. In the previous example, the ToString method of the integer object, outcome, is used to convert the integer value of outcome into the equivalent string value. This conversion is necessary because the value is displayed in the T ext property of the result fieldââ¬âthe Text property can only contain strings. When you Controlling Precedence Precedence governs the order in which an expression's operators are evaluated. Consider the following expression, which uses the + and * operators: 2+3*4This expression is potentially ambiguous; does 3 bind to the + operator on its le
Subscribe to:
Posts (Atom)