473,396 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Unreachable code detected!!!! pls hlp

Expand|Select|Wrap|Line Numbers
  1. String position = cboPositions.Text;
  2.             switch (position)
  3.             {
  4.                 case "Absolute":
  5.                     x = 1; y = 1;
  6.                     break;
  7.                 case "TopLeft":
  8.                     x = 0; y = 0;
  9.                     break;
  10.                 case "TopRight":
  11.                     x = (int)(picContainer.Image.Width - sz.Width); y = 0;
  12.                     break;
  13.                 case "TopMiddle":
  14.                     x = (int)(picContainer.Image.Width - sz.Width) / 2; y = 0;
  15.                     break;
  16.                 case "BottomLeft":
  17.                     x = 0; y =(int) (picContainer.Image.Height - sz.Height);
  18.                     break;
  19.                 case "BottomRight":
  20.                     x = (int)(picContainer.Image.Width - sz.Width); y = (int)(picContainer.Image.Height - sz.Height);
  21.                     break;
  22.                 case "BottomMiddle":
  23.                     x =(int) (picContainer.Image.Width - sz.Width) / 2; y =(int) (picContainer.Image.Height - sz.Height);
  24.                     break;
  25.                 case "MiddleLeft":
  26.                     x = 0; y =(int) (picContainer.Image.Height - sz.Height) / 2;
  27.                     break;
  28.                 case "MiddleRight":
  29.                     x =(int) (picContainer.Image.Width - sz.Width); y = (int)(picContainer.Image.Height - sz.Height) / 2;
  30.                     break;
  31.                 case "Center":
  32.                     x =(int)(picContainer.Image.Width - sz.Width) / 2; y =(int) (picContainer.Image.Height - sz.Height) / 2;
  33.                     break;
  34.                 default:
  35.                     break; 
  36. g.DrawString(txtWaterMark.Text, myFont, myBrush, new Point(x, y));
  37.  
how can i correct this code!!!! im using this code so tat i can place my watermark onto those positions!!! if there is any other alternative pls do suggest :) the code which is in bold is the place im getting tat warning... and not getting any output at all
Apr 4 '11 #1
5 2502
Aimee Bailey
197 Expert 100+
on line 35, put the break; at the end of the line, not at the beginning.
Apr 4 '11 #2
i tried tat also!! still no use and im getting tat warning in this piece of code
Expand|Select|Wrap|Line Numbers
  1.  g.DrawString(txtWaterMark.Text, myFont, myBrush, new Point(x, y));
Apr 4 '11 #3
Aimee Bailey
197 Expert 100+
When posting here, please make sure to elaborate (explain fully) the problem you are having. "tat warning" does not help members of this forum understand the issue, and will mean it takes longer to get an answer.

Please provide information on what error you are getting, there are a few possibles I can imagine:

- null reference exception based on g, the Graphics class is a disposable type, which means the garbage collector can destroy it if you show you don't intend on using it.

- x or y may not have a value set.

- break; means the switch exits. If you have code after it, it will be ignored.


Aimee.
Apr 4 '11 #4
Rabbit
12,516 Expert Mod 8TB
You need to close your switch statement.
Apr 4 '11 #5
Plater
7,872 Expert 4TB
You're missing the close brace of your switch statement.
I am surprised it compiled at all.
Apr 7 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: SteadySteps | last post by:
Hi I migrated a project which compiles correctly on VC 6.0 to VS 2002. However now all I get several warning that all the statements within catch blocks are "unreachable code". How can I correct...
2
by: Hovik Melikyan | last post by:
This code produces a 'unreachable code' warning at line 16 (throw new X ...) with no visible reason: #include <string> class X { std::string msg;
6
by: dfetrow410 | last post by:
Can I do this in an if statement? public string getClass() { counta = counta + 1; if (counta < 2 ) {
4
by: Gernot Frisch | last post by:
I get informed that parts of my code cannot be reached. Did I do something wrong? try { if (login(progstring) > 0) { return 1; // OK } }
1
by: tam | last post by:
when i am using session variable i found one error that unreachable core error. how to rectify this error
3
by: Don Burden | last post by:
We've started converting some applications to the .NET 2.0 framework. When compiling in VS 2005, I'm getting a warning on this line: return (unitWidth != null ) ? unitWidth : new Unit("0px"); ...
8
by: teddysnips | last post by:
I'm new to C# - recent background mainly ASP.NET with VB.NET. Anyhoot, I needed to create a C# statement analogous to VB's IIf: VB.NET Dim e As Boolean e = IIf((CInt(MyVariable) 0), True,...
3
by: cie | last post by:
Hi, anyone please help me when I try to close a connection to the database from a static method, "Unreachable code detected" error occured. What's the problem actually? Thank you before
1
by: ITC | last post by:
When i write web method in C#. I got a warning and can't get the right result though it run. Code is below. public string CurrencyConverter(double amt, string fromCurrency, string...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.