0

This program is about to determine the r Value which are following this statement:

int rV;
if ( (p-1) % rV == 0 && rV % ( (p-1) / rV ) == 1 && rV % (q-1) == 1 )
  tbKr.Text = rV.ToString();
rV = Convert.ToInt32(tbKr.Text);

And this is the error:

Use of unassigned local variable 'rV' (CS0165)

Thank you so much for your help.

Ariga
  • 11
  • 2
  • 1
    You haven't assigned any value to `rV`, so doing a bunch of calculation with it doesn't make much sense does it? – Retired Ninja Jun 28 '21 at 21:10
  • 2
    You're referring to `rV` in the `if` statement - it does not have a value yet at that point. – 500 - Internal Server Error Jun 28 '21 at 21:10
  • [C# Naming Conventions](https://www.c-sharpcorner.com/UploadFile/8a67c0/C-Sharp-coding-standards-and-naming-conventions/) • [C# Coding Standards and Naming Conventions](https://github.com/ktaranov/naming-convention/blob/master/C%23%20Coding%20Standards%20and%20Naming%20Conventions.md) • [C# Coding Conventions (C# Programming Guide)](https://learn.microsoft.com/dotnet/csharp/programming-guide/inside-a-program/coding-conventions) –  Jun 28 '21 at 21:12

1 Answers1

-1

In first "if" you use rv:

rV%((p-1)/rV)==1

but this variable has no value i.e. unassigned. You can't use variable before you set value.

PVA
  • 24
  • 2