1 / 5

Typer i programmering

Typer i programmering. Simple typer. v ar a = 13; <- int : heltal var str = ”hallo”; <- s tring : tekststreng v ar sand = true; <- b ool : true/false var b = 1.4; <- decimal : kommatal. Objekter. Har tilstand (properties) som kan tilgås (nogle kan ændres)

alain
Download Presentation

Typer i programmering

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Typer i programmering

  2. Simple typer • var a = 13; <- int : heltal • var str = ”hallo”; <- string : tekststreng • var sand = true; <- bool : true/false • var b = 1.4; <- decimal : kommatal

  3. Objekter • Har tilstand (properties) som kan tilgås (nogle kan ændres) • Har metoder der kan gøre noget (svarende til function i JavaScript) Eksempel: Request objektet: • Request.Form <- property • Request.QueryString <- property • Request.ValidateInput() <- metode

  4. Request objektet submit @{ var num1 = Request.Form[”number1”]; var multTen = num1 * 10;

  5. Konvertering af typer • Problem: Vi har en tekststreng der egentlig er et tal, men det ved programmet ikke. • Løsning: AsInt() metoden • Tilsvarende for andre typer. • Alle typer har en toString() metode som returnerer en streng @{ var str1 = Request.Form[”number1”]; var num1 = str1.AsInt(); var multTen = num1 * 10; }

More Related