---
title: "Fall through i Switch sats"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/81442-fall-through-i-switch-sats"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "Viktor"
published: "2003-07-06T17:27:10.000Z"
updated: "2003-07-07T08:05:48.000Z"
replies: 3
views: 222
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/81442-fall-through-i-switch-sats"
---

# Fall through i Switch sats

## #1 — Viktor, 2003-07-06T17:27Z

Jag vill ha en switch sats som ser ut såhär

```
switch(xmlIterator.Current.Name)
{
	case "name":
		Console.WriteLine("Name: "+xmlIterator.Current.Value);
		break;
	case "info":
		Console.WriteLine("Info: "+xmlIterator.Current.Value);
		break;
	case "pointinfo":
		xmlIterator.Current.MoveToFirstChild();
	case "pointpos":
		xmlIterator.Current.MoveToFirstAttribute();
		Console.Write("Pos: {0}",xmlIterator.Current.Value);
		xmlIterator.Current.MoveToNextAttribute();
		Console.WriteLine(", Points: {0}",xmlIterator.Current.Value);
		break;
};
```

dvs när den kommer ner till "pointinfo" så ska den göra det som står där och sedan gå vidare och göra det som står under "pointpos", men när jag försöker göra det så får jag 

> Controll cant fall through one case lable to another.

Finns det något sätt att göra så det går?

/Viktor

Permalänk: https://www.webforum.nu/p/81442

## #2 — Dino, 2003-07-06T17:35Z

Re: Fall through i Switch sats

Kanske så här?

```
bool grr;
switch(xmlIterator.Current.Name)
{
	case "name":
		Console.WriteLine("Name: "+xmlIterator.Current.Value);
		break;
	case "info":
		Console.WriteLine("Info: "+xmlIterator.Current.Value);
		break;
	case "pointinfo":
		xmlIterator.Current.MoveToFirstChild();
                                grr = true;
                                break;
	case "pointpos":
		xmlIterator.Current.MoveToFirstAttribute();
		Console.Write("Pos: {0}",xmlIterator.Current.Value);
		xmlIterator.Current.MoveToNextAttribute();
		Console.WriteLine(", Points: {0}",xmlIterator.Current.Value);
		break;
};
if(grr == true){
   //do stuff
   grr = false
}
```

Permalänk: https://www.webforum.nu/p/1104957

## #3 — Grynet, 2003-07-07T06:57Z

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfTheSwitchStatement.asp>

Permalänk: https://www.webforum.nu/p/1105237

## #4 — Viktor, 2003-07-07T08:05Z

Tack, det var något sånt som jag ville ha.

/Viktor

Permalänk: https://www.webforum.nu/p/1105259

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/81442-fall-through-i-switch-sats
