How to compare STRING in Uity?

hey , I,ve two Script attached to two different GameObjects,I wanna compare one ‘String’ of one Script with the ‘String’ of another Script to check whether they are same or not…

i don’t know your usage, so i’ll pretend this is some script that just finds two Components and compares two fields. Your mileage may very as i can’t guess how your objects are setup and should be referenced, however.

// c#
using UnityEngine;
using System;

public class ClassThatCompares : MonoBehaviour
{
	public CustomScript1 script1;
	public CustomScript2 script2;

	void Awake()
    {
	    script1 = GameObject.Find("script1GameObject").GetComponent<CustomScript1>();
		script2 = GameObject.Find("script1GameObject").GetComponent<CustomScript2>();
    }

    void Update()
    {
		// Check to ensure script1 and script2 are not null and that the properties are equal.
		if ((script1 && script2) && script1.SomeStringFieldOrProperty == script2.SomeStringFieldOrProperty)
		{
			Debug.Log("The strings are equal.");
		}
	}
}

// javascript/unityscript

public script1 : CustomScript1;
public script2 : CustomScript2;

function Awake() {
	script1 = GameObject.Find("script1GameObject").GetComponent.<CustomScript1>();
	script2 = GameObject.Find("script1GameObject").GetComponent.<CustomScript2>();
}

function Update() {
		// Check to ensure script1 and script2 are not null and that the properties are equal.
		if ((script1 && script2) && script1.SomeStringFieldOrProperty == script2.SomeStringFieldOrProperty) {
			Debug.Log("The strings are equal.");
		}
}