C# Error help ( error CS0023 The `!’ operator cannot be applied to operand of type `string’ ) ???

Hey guys, I’ve been coding with Unityscript for about 2 years now and so I thought I should move onto C# for some benefits and just to learn something new, and as expected with learning a new language is to get errors, but this one is one that I can’t just search up and find so I’m gonna need more advanced help I guess. The error is this:

line: (19,42) error CS0023: The ‘!’ operator cannot be applied to operand of type ‘string’ .

So really all I’m asking for is an answer to this error and an explanation to why I’m getting it in the first place to stop it in the future. Thanks in advance :slight_smile: .

using UnityEngine;
using System.Collections;

public class PickupRay : MonoBehaviour {
	
	public GameObject mainPlayer;
	public string pickupTagIdentifyer;
	public bool picked;
	public bool canpick;
	public Transform grabTrans;
	private RaycastHit hit;
	public float maxDistance = 1.4444f;
	public float weight = 1.0f;

	void Update () {

		canpick = false;
		if(!picked){
			if(!hit.collider.tag == pickupTagIdentifyer || !(hit.collider.GetComponent(PickupObject) == null)){

			}
		}
	}
}

Try this :

if( !(hit.collider.tag == pickupTagIdentifyer) || !(hit.collider.GetComponent(PickupObject) == null) ){

The ! was “applied” to hit.collider.tag only.