Variable used in LINQ method is throwing NullReferenceException on initialization?
While debugging code today, I ran into a NullReferenceException
that should be impossible. It was on the assignment of an empty string ""
, not string.Empty
(though they should be equivalient IIRC) to a new variable declaration:
Here's the code in a copypasta form:
string city = "";
string state = ""; // Throws null reference exception.
I initially thought that maybe, just maybe, somehow the same variable was declared elsewhere and wasn't throwing a compiler error, but after running a search through the code, that variable is created there, no where else.
From there, the second thought was that maybe the PDB
files were out of sync, which was supported in comments from other SO users here. As such, a clean and re-build was in order, but alas did not resolve my issue.
I then cross compared my changes against the containing repo and noticed that my only change was to add a check to see if the variable state
contained a known state abbreviation using a call to .Any
:
List<string> validStates = StateList.Split(',').ToList();
if (validStates.Any(validState => validState.Equals(state, StringComparison.InvariantCultureIgnoreCase)))
... // Unchanged
I changed this to use .Contains
instead and the issue disappeared:
List<string> validStates = StateList.Split(',').ToList();
if (validStates.Contains(state.ToUpperInvariant()))
... // Unchanged
Thinking this was a fluke, I did another clean & rebuild with the .Any
call and it still failed, leading me to believe the issue is with the call to .Any
. However, the call to this is almost 50 lines after the declaration of the variable state
which makes no sense as to why it would cause the issue.
SO user @madreflection pointed out in the comments that this could be related to the capture by the lambda expression and could be leading to unexpected behavior, and requested that I try moving the declaration closer to the call to .Any
. Due to the logic above, I couldn't move the creation of the statement, downward, but I did create a new variable, assigning it a value of ""
and changed back to .Any
using the test variable instead. The issue is for sure still occurring, but this time on the creation and initialization of my test variable:
Here's the code from that screenshot in copypasta form:
string state = "";
...
string testState = "";
testState = state;
if (!string.IsNullOrWhiteSpace(testState)) {
List<string validStates = StateList.Split(',').ToList();
if (validStates.Any(validState => validState.Equals(testState, StringComparison.InvariantCultureIgnoreCase)))
... // Unchanged
}
As another update, I removed all the code between the declaration and the use of .Any
and the error is still occurring. Also, I attempted to give the variable a valid starting value such as "AK"
and it still blew up.
Why would assigning an empty string value to a variable throw a NullReferenceException
when using the LINQ method .Any
almost 50 lines later?
NOTE: There is no inner exception, and we have no other ideas as to what could cause this. If anyone has ideas I'll gladly update the post with more information.
See also questions close to this topic
-
SqlDataReader can only check for one of (Null or non null value)
I am writing a program (for personal use) that stores card names into a database. I want to implement a way to see if a name already exists and if it does it will go in a "Do_have_in_db_listbox" else it will go in a "do_not_have_list_box". This is my original method for doing so:
while (retrieve.Read()) { if(retrieve["Card"] != DBNull.Value) { listBox_haveInDB.Items.Add(word_for_query); } else if (retrieve["Card"] == DBNull.Value) { listBox_notINDb.Items.Add(word_for_query); } }
I've tried this without the While loop, I've tried variations of if, else, else if and conditions. But for whatever reason the else statement NEVER executes no mater what the first condition is. I've been looking and trying to trouble shoot but the only thing that worked for me was an exception handler:
retrieve.Read(); try { if(retrieve["Card"] != DBNull.Value) { listBox_haveInDB.Items.Add(word_for_query); } } catch { listBox_notINDb.Items.Add(word_for_query); }
This is my way of getting around it. What am I doing wrong?
-
I want it to close when it opens the exe file separately
I have two exe files coded in C# and C++. What I want to do is to download and run the exe coded with C++ from C#. When the C++ application is not brought from the C# application, I do not want it to be launched directly from the downloaded folder. How can I do this?
-
How to filter DataGrid with SelectedItem from ItemsView using WPF?
Quick Summary
I have managed to code up this output so far
XAML
<Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <StackPanel Grid.Column="0"> <DataGrid ItemsSource="{Binding AddressView}"> </DataGrid> </StackPanel> <StackPanel Grid.Column="1"> <ListView ItemsSource="{Binding PersonView}"> <ListView.View> <GridView> <GridViewColumn Header="Id" DisplayMemberBinding="{Binding Id}" /> <GridViewColumn Header="Id" DisplayMemberBinding="{Binding Name}" /> </GridView> </ListView.View> </ListView> </StackPanel> </Grid>
PersonModel
public class PersonModel { public int Id { get; set; } public string Name { get; set; } public ObservableCollection<PersonModel> GetPersonModels() { ObservableCollection<PersonModel> people = new ObservableCollection<PersonModel>(); people.Add(new PersonModel { Id = 1, Name = "John" }); people.Add(new PersonModel { Id = 2, Name = "Max" }); people.Add(new PersonModel { Id = 3, Name = "Ed" }); return people; } }
AddressModel
public class AddressModel { public int Id { get; set; } public string Address { get; set; } public int PersonId { get; set; } public ObservableCollection<AddressModel> GetAddressModels() { ObservableCollection<AddressModel> addresses = new ObservableCollection<AddressModel>(); addresses.Add(new AddressModel { Id = 1, Address = "Address 1", PersonId = 1 }); addresses.Add(new AddressModel { Id = 2, Address = "Address 1", PersonId = 2 }); addresses.Add(new AddressModel { Id = 3, Address = "Address 2", PersonId = 3 }); return addresses; } }
ViewModel
public class ViewModel : BaseViewModel { // Initializer public ViewModel() { CopyOfPersonModel = new PersonModel(); CopyOfAddressModel = new AddressModel(); RefreshData(); } // Person Models properties private ObservableCollection<PersonModel> _personModels; public ObservableCollection<PersonModel> PersonModels { get { return _personModels; } set { _personModels = value; OnPropertyChanged(); } } public PersonModel CopyOfPersonModel { get; set; } // Person View - Used by the View private ICollectionView _personView; public ICollectionView PersonView { get { return _personView; } set { _personView = value; OnPropertyChanged(); } } // Address Models properties private ObservableCollection<AddressModel> _addressModels; public ObservableCollection<AddressModel> AddressModels { get { return _addressModels; } set { _addressModels = value; OnPropertyChanged(); } } public AddressModel CopyOfAddressModel { get; set; } // Address View - Used by the View private ICollectionView _addressView; public ICollectionView AddressView { get { return _addressView; } set { _addressView = value; OnPropertyChanged(); } } // Method to refresh the data public void RefreshData() { // Refresh the collections from the Model method PersonModels = CopyOfPersonModel.GetPersonModels(); AddressModels = CopyOfAddressModel.GetAddressModels(); // Refresh the views PersonView = CollectionViewSource.GetDefaultView(PersonModels); AddressView = CollectionViewSource.GetDefaultView(AddressModels); } }
Goal
My current goal is to filter the Address View on the left hand side of the MainWindow via the the ListView on the right hand side.
For example: Selected
Id
from the ListView is1
. Then filter the Address View in the DataGrid where PersonId =1
.What I have tried
I added a Filter method and a Search property:
// Filtering private bool Filter(AddressModel address) { return Search == address.PersonId; } private int search; public int Search { get { return search; } set { search = value; OnPropertyChanged(); AddressView.Refresh(); } }
and within my
RefreshData()
at the bottom I have added this line of code to enable filtering.// Filter AddressView.Filter = new Predicate<object>(o => Filter(o as AddressModel));
Problem
This fully works if I bind the
Search
property to a TextBox<TextBox Text="{Binding Search, UpdateSourceTrigger=PropertyChanged}" />
And the DataGrid filters as intended.
But if I try to filter via selected item from ListView like so.. it does not work.
<ListView ItemsSource="{Binding PersonView}" SelectedItem="{Binding Search}" SelectedValue="{Binding Id}"> <ListView.View> <GridView> <GridViewColumn Header="Id" DisplayMemberBinding="{Binding Id}" /> <GridViewColumn Header="Id" DisplayMemberBinding="{Binding Name}" /> </GridView> </ListView.View> </ListView>
-
Difference between "+=" and "-=" in javascript: number or string
I found that "+=" and "-=" behave differently in JS.
"-=" directly considered as math number, while "+=" considered as string by default.
Example below:
let total = document.getElementById("total"); // e.g. a simple empty span element in html const btnminus = document.getElementById("btnminus"); const btnplus = document.getElementById("btnplus"); btnplus.addEventListener( "click", () => { total.innerHTML += 1; }); // "1" is considered as string, click and get 11111111 btnminus.addEventListener( "click", () => { total.innerHTML -= 1; }); // "1" is considered as integer number, click and get decrement (-1)
To get the += work, the innerHTML has to be converted to Number first, as follows
btnplus.addEventListener( "click", () => { total.innerHTML = Number(totalorder.innerHTML) + 1; }); // convert to number, click and get increment (+1)
I understand the phenomenon but don't know the exact difination of these two operators.
Can anyone please explain?
-
R find two words into same string
I want to create a single regex or str_detect (if possible) to search through text strings and determine if two words (countries) occur in the same string based on one country list, but testing without repetition. For example:
latam <- c("BRAZIL", "MEXICO", "CHILE", "ARGENTINA", "COLOMBIA", "CUBA", "VENEZUELA", "PERU", "COSTA RICA", "ECUADOR", "URUGUAY", "BOLIVIA", "PARAGUAY", "GUATEMALA", "EL SALVADOR", "PANAMA", "NICARAGUA", "DOMINICAN REPUBLIC", "HONDURAS", "HAITI") example_string <- c("USA;BRAZIL", "USA;BRAZIL;ARGENTINA", "BRAZIL;BRAZIL;ARGENTINA", "BRAZIL;ARGENTINA", "BRAZIL;BRAZIL", "BRAZIL;BRAZIL;ARGENTINA;ARGENTINA")
Testing
example_string
, the desired output is:FALSE
,TRUE
,TRUE
,TRUE
,FALSE
,TRUE
. -
Sort an indexed array of ISO date strings in PHP
I've got an indexed (non associative) array of ISO date strings in PHP:
$myDates = ['2021-04-01', '2021-04-03', '2021-04-02'];
How can I sort these in ascending order? I was looking at the
asort
function but that appears to only work forassociative arrays
, and the result of$mySortedDates
usingasort
wastrue
rather than an array of sorted ISO date strings. All of the PHP date sorting examples I found on StackOverflow were for associative arrays * braces for downvotes * -
Why doesn't my thrown exception bubble up to my higher level try-catch?
I have a large node.js app written by me. It is JS code converted from a legacy VB.Net program of mine that has many "Throw New NamedException" statements scattered around. These are carried over to my JS app and I created a hierarchical try/catch structure to handle them. But an exception I'm throwing at the bottom doesn't bubble up as I expected. Here is a simplified model of the code.
function A() { try { /* do somthing */ B() // call subroutine } catch (err) { if (err instanceof CalcAbortError) { /* do something here */ } else { throw err // not handled here } } } function B() { try { /* do somthing */ throw new ArgumentError(message) } catch (err) { runCatcher(err) // this handles err and throws, never to return } } function runCatcher(err) { if (err instanceof CalcAbortError) { throw err // pass it up } else if (err instanceof ArgumentError) { throw new CalcAbortError('ArgumentError', err) // ** } } class CalcAbortError extends Error { // top level catch for aborting calculation and returning error message constructor(message, cause) { super(message) this.cause = cause this.name = 'CalcAbortError' } } class ArgumentError extends Error { constructor(message) { super(message) this.name = 'ArgumentError' } }
Function A is the top level where I want to capture the CalcAbortError exception. Function A calls function B which stands in for the bulk of my code. Somewhere in that intermediate code a new ArgumentError exception is thrown. This is caught in the function B's catch clause. Because of the large number of different custom exceptions I have, I am using a subroutine (runCatcher) to handle caught exceptions from every try/catch in the B function.
The runCatcher routine handles all possible custom exceptions, including the CalcAbortError exception, in the different levels of my try/catch hierarchy, except at the highest level in function A. When I run a Jest test, i see the exception "CalcAbortError: ArgumentError" shown to me at the line with the double ** comment. I am assuming this means it was not handled in a higher level try/catch. What's wrong with my approach?
-
Is there a way to intercept ALL JavaScript errors?
Goal: When any JS error occurs, grab the information from that error and execute a custom function with it.
Description: If a script creates an error like this...
var a = test; // VM334:1 Uncaught ReferenceError: test is not defined
...how can I "intercept" that error; perhaps something like this:
Error.onerror = function(e){ alert("The error is " + e ); } // "The error is VM334:1 Uncaught ReferenceError: test is not defined"
Note: I am aware of the following:
window.onerror = function(){...} window.addEventListener('error', ... )
Unfortunately these do not get the job done for reasons I believe are related to scope. I believe many errors will fail to be tracked because they do not live on the window object.
try{}catch(e){alert(e)}
is also not a solution because it is too particular about where the errors come from.I have also tried overwriting
console.error
but this function is not called when a JS error occurs on page.Is there a way to respond to ANY JS error?
Cheers
-
Multiple User Defined Exceptions in java
So the scenario is to limit a user to perform three transactions a day, I wanted to finish the part where the exception is to be raised any help would be appreciated.
import java.util.Scanner; class FundsNotAvailable extends Exception{ FundsNotAvailable(String s){ super(s); } } class ExceededTransactionsLimit extends Exception{ ExceededTransactionsLimit(String s){ super(s); } } class BankMethods { String accName; String accNumber; Integer balance; public Integer transactions = 0; Scanner sc = new Scanner(System.in); void AccOpen() { System.out.println("Enter Account Holder Name: "); accName = sc.next(); System.out.println("Enter Account Number: "); accNumber = sc.next(); System.out.println("Enter the Deposit amount: "); balance = sc.nextInt(); } void Deposit() { Integer amount; System.out.println("Enter the Amount you wish to Deposit:"); amount = sc.nextInt(); balance = balance + amount; } void Withdrawal() throws FundsNotAvailable, ExceededTransactionsLimit { Integer amount; System.out.println("Enter the Amount you wish to Withdraw:"); amount = sc.nextInt(); if (amount > balance) { throw new FundsNotAvailable("Insufficient Funds"); } if(transactions > 3) { throw new ExceededTransactionsLimit("You have exceeded the daily transactions limit"); } balance = balance - amount; System.out.println(transactions); } void showBalance() { System.out.println("The Balance in your Account is:" + balance); } } public class Bank { public static void main(String[] args) { Scanner sc = new Scanner(System.in); BankMethods BM = new BankMethods(); BM.AccOpen(); Integer choice; do { System.out.println("Main Menu \n 1. Deposit \n 2. Withdraw \n 3. Show Balance \n 4. Exit"); System.out.println("Please Make A Choice:"); choice = sc.nextInt(); switch (choice) { case 1: BM.Deposit(); break; case 2: try { BM.Withdrawal(); } catch (ExceededTransactionsLimit | FundsNotAvailable e) { System.out.println(e.getMessage()); } break; case 3: BM.showBalance(); break; case 4: System.out.println("Good Bye"); break; } } while (choice != 4); } }
the condition transactions > 3 is working fine when i run it in the main class but isnt throwing an exception when i run it in the method i even tried to keep track of the transcations variable value and it kept increasing everytime i performed the withdraw operation.
Thank you (any help is appreciated)
-
System.NullReferenceException: 'Object reference not set to an instance of an object.' error in visual studio 2019
Firstly i tried to research on my problem and read these solutions but none of them made me understand the problem in this code. I am getting this error when i try to compile my program but only the 39th line of my code is initializing "null" variable. I can't change that because i want to use it that way and i don't know if it is letting me trouble.
Customer customer = null;
read articles:
System.NullReferenceException: Object reference not set to an instance of an object
What is a NullReferenceException, and how do I fix it?
my code:
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; namespace ConsoleApplication123 { class Program { static void Main(string[] args) { List<Customer> cList = new List<Customer>(); using (StreamReader sr = new StreamReader("C:/Mehmet/ConsoleApp42/firstDisk.json")) { string cjson = sr.ReadToEnd(); cList = JsonConvert.DeserializeObject<List<Customer>>(cjson); } Console.WriteLine("There are " + cList.Count + " Customers Name in Input json file."); Console.WriteLine("Details are as follows: "); foreach (Customer c in cList) { Console.WriteLine("Id: " + c.Id); Console.WriteLine("Name: " + c.Name); Console.WriteLine("Contact Info: "); string[] contacts = c.Contact.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in contacts) { Console.WriteLine(s); } Console.WriteLine("Bill: " + c.Bill); Console.WriteLine("Email: " + c.Email); } string option = ""; int Id = 0; string searchText = string.Empty; Customer customer = null; Console.WriteLine("Select Option Display, Search, Create Email, Exit"); while (!(option = Console.ReadLine()).Equals("Exit")) { switch (option) { case "Display": Console.Write("Enter Id of the Customer: "); int.TryParse(Console.ReadLine(), out Id); customer = (from c in cList where c.Id == Id select c).FirstOrDefault(); if (customer != null) { Console.WriteLine("Contact Info for Id: " + Id); Console.WriteLine("Id: " + customer.Id); Console.WriteLine("Name: " + customer.Name); string[] contacts = customer.Contact.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in contacts) { Console.WriteLine(s); } Console.WriteLine("Bill: " + customer.Bill); Console.WriteLine("Email: " + customer.Email); } else { Console.WriteLine("No Contact Info for Id: " + Id); } Console.WriteLine("Select Option Display, Search, Create Email, Exit"); break; case "Search": Console.Write("Enter Name of the Customer: "); searchText = Console.ReadLine(); customer = (from c in cList where c.Name.Equals(searchText) select c).FirstOrDefault(); if (customer != null) { Console.WriteLine("Contact Info Name: " + searchText); Console.WriteLine("Id: " + customer.Id); Console.WriteLine("Name: " + customer.Name); string[] contacts = customer.Contact.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in contacts) { Console.WriteLine(s); } Console.WriteLine("Bill: " + customer.Bill); Console.WriteLine("Email: " + customer.Email); } else { Console.WriteLine("No Contact Info for Id: " + Id); } Console.WriteLine("Select Option Display, Search, Create Email, Exit"); break; case "Create Email": Console.Write("Enter Id of the Customer: "); int.TryParse(Console.ReadLine(), out Id); customer = (from c in cList where c.Id == Id select c).FirstOrDefault(); if (customer != null) { string[] cparts = customer.Name.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); string emailId = cparts[0][0] + cparts[1] + customer.Id + "@grandcankaya.com"; Console.WriteLine("Email Id Just Created Is: " + emailId); int index = cList.IndexOf(customer); if (index >= 0) { cList[index].Email = emailId; } using (StreamWriter sw = new StreamWriter("C:/Mehmet/ConsoleApp42/finalDisk.json")) { sw.WriteLine(JsonConvert.SerializeObject(cList)); } Console.WriteLine("Contact Info for Id: " + Id); Console.WriteLine("Id: " + customer.Id); Console.WriteLine("Name: " + customer.Name); string[] contacts = customer.Contact.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in contacts) { Console.WriteLine(s); } Console.WriteLine("Bill: " + customer.Bill); Console.WriteLine("Email: " + customer.Email); } else { Console.WriteLine("No Contact Info for Id: " + Id); } Console.WriteLine("Select Option Display, Search, Create Email, Exit"); break; case "Exit": Console.WriteLine("Select Option Display, Search, Create Email, Exit"); break; default: Console.WriteLine("Select Option Display, Search, Create Email, Exit"); break; } } Console.Write("Press Any Key To Exit."); Console.ReadKey(); } } public class Customer { public int Id { get; set; } public string Name { get; set; } public decimal Bill { get; set; } public string Contact { get; set; } public string Email { get; set; } } }
the issue i am having:
this is my json file at first:
[ { "FirstName": "Kaan", "LastName": "OZAYDIN", "EmployeeId": 101, "Email": "", "Password": "", "Address": { "ZipCode": "06460", "State": "Ankara", "Country": "Turkey" } }, { "FirstName": "Erkan", "LastName": "YILDIZ", "EmployeeId": 102, "Email": "", "Password": "", "Address": { "ZipCode": "06460", "State": "Ankara", "Country": "Turkey" } } ]
what is wrong with the code? please let me know, if you can. Also that was a homework but since i don't get the coding, i won't upload it. Time doesn't matter, just wanted to learn.
-
Attempt to invoke virtual method 'void android.widget.ProgressBar.setVisibility(int)' on a null object reference
I am trying to make a progress load bar before data loading and making it invisible after load. below is my code for this. I have tried all possible but still exception doesn't seems to getting resolve.
progressBar.setVisibility(INVISIBLE) viewModel.init(args.referenceType, args.referenceValue) progressBar.setVisibility(VISIBLE)
init function inside viewmodel call api and fetch data.
.xml is:
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:id="@+id/progressBar" android:progress="0" android:visibility="invisible" />
error is:
Attempt to invoke virtual method 'void android.widget.ProgressBar.setVisibility(int)' on a null object reference
-
I have been getting a NullReferenceException error and it just doesn't go! Can someone help me out with this situation?
Hey guys I am getting this error in my unity console I want to make a 2d sword combat game. But I am not able to damage the enemy. Pls Help!
NullReferenceException: Object reference not set to an instance of an object DoDamage.doDamage () (at Assets/Scripts/DoDamage.cs:16) PlayerAttack.SwordCombat () (at Assets/Scripts/PlayerAttack.cs:54) PlayerAttack.Update () (at Assets/Scripts/PlayerAttack.cs:25)
My PlayerAttack script This script is attached to player All the public GameObjects in this script are filled
public class PlayerAttack : MonoBehaviour { public Animator anim; private Vector2 movement; private Vector2 sprint; private float doubleClickTime = 0.2f; private float lastClickTime; [SerializeField] public bool punched; public bool isArmed = false; private GameObject sword; void Start(){ movement = gameObject.GetComponent<PlayerMove>().movement; sprint = gameObject.GetComponent<PlayerMove>().sprinting; } void Update () { if(isArmed){ sword = gameObject.GetComponent<PickupWeapon>().sword; SwordCombat(); }else{ HandCombat(); } } public void HandCombat(){ if(Input.GetKeyDown(KeyCode.Mouse0)){ float timeSinceLastClick = Time.time - lastClickTime; if(timeSinceLastClick < doubleClickTime && punched){ anim.SetTrigger("DoublePunch"); punched = false; }else{ anim.SetTrigger("Punch 1"); punched = true; } lastClickTime = Time.time; } } public void SwordCombat(){ if(Input.GetKeyDown(KeyCode.Mouse0)){ float timeSinceLastClick = Time.time - lastClickTime; if(timeSinceLastClick < doubleClickTime && punched){ anim.SetTrigger("DoubleSwordAttack"); sword.GetComponent<DoDamage>().doDamage(); punched = false; }else{ anim.SetTrigger("SwordAttack"); sword.GetComponent<DoDamage>().doDamage(); punched = true; } lastClickTime = Time.time; } } }
My DoDamage script
This script is responsible to damage the enemy
public class DoDamage : MonoBehaviour { public Transform attackPoint; public float attackRange = 0.5f; public LayerMask enemyLayers; private GameObject damageTaker; public void doDamage(){ Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, enemyLayers); foreach(Collider2D enemy in hitEnemies){ enemy.gameObject.GetComponent<Control>().TakeDamage(50f); } } void OnDrawGizmosSelected(){ if(attackPoint == null){ return; } Gizmos.DrawWireSphere(attackPoint.position, attackRange); } }
My Control script
This script is attached to enemy and contain its key features
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Control : MonoBehaviour { public float speed = 8f; public float maxHealth = 100; float currentHealth; void Start(){ currentHealth = maxHealth; } public void TakeDamage(float damage){ currentHealth -= damage; if(currentHealth <= 0){ Die(); } } public void Die(){ Debug.Log("Enemy Died!"); } }
I have tried number of solutions. I have wrote this code using one of the brackeys tutorial on 2D combat system. It has the same code as mine but I am getting errors.
I dont know what does the error mean and not getting a perfect solution. Pls Help!